about | help | code help+videos | done | prefs |
singleDigitSumRecursive
Define a function that when passed an integer, returns the single-digit sum of its digits. For example, if n = 999999997, the sum of the digits is 79, but since its not a single-digit number, we compute the sum of its digits, which is 16. It's still not a single-digit number, so we repeat the process, finally yielding 7. singleDigitSumRecursive(999999997) → 7 singleDigitSumRecursive(39) → 3 singleDigitSumRecursive(100) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 2 Post-solution available
Copyright Nick Parlante 2017 - privacy