id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2024_11_21_SLHL_recursiveSumDigits
prev  |  next  |  chance

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)

public int test2024_11_21_SLHL_recursiveSumDigits(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 320

Copyright Nick Parlante 2017 - privacy