LeetCode 258. Add Digits in F#

URL

Add Digits - LeetCode

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/challenge/202304/add_digits/main.fsx

let addDigits (num: int) : int =
    let rec digitSum n acc =
        if n = 0 then acc else digitSum (n / 10) (acc + (n % 10))

    let rec addDigits' num =
        if num < 10 then num else addDigits' (digitSum num 0)

    addDigits' num