about | help | code help+videos | done | prefs |
Write a method that returns the "recursive sum of the digits" of the non-negative integer input parameter 'num'. For example, if 'num' is 213897, you would first compute the sum of those digits 2+1+3+8+9+7=30. Since this result is NOT a single digit, you would then compute the sum of those digits 3+0=3. You now have a single-digit result, so you return that result. Look at the test data for additional examples. This problem is much easier to do with recursion, but may also be possible using other methods. Recursion is recommended, but not required. test2024_11_21_SLHL_recursiveSumDigits(10) → 1 test2024_11_21_SLHL_recursiveSumDigits(49387) → 4 test2024_11_21_SLHL_recursiveSumDigits(92378) → 2 ...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: 320
Copyright Nick Parlante 2017 - privacy