about | help | code help+videos | done | prefs |
diSum
Given an non-negative integer parameter, return the "disum" of that number. The "disum" is computed by finding the sum of all the digits of the number, then finding the sum of all the digits of that number, and continuing in this process until a single-digit number is obtained. For example, the "disum" of 594 is 9 because 5+9+4=18, then 1+8=9, which is a single-digit number, so we are done! Another example is 9999 which has a "digsum" of 9 because 9+9+9+9+9=36, then 3+6=9. Just so you don't think the answer is always 9, lets find the "digsum" of 511. 5+1+1=7. In this case we don't need to repeat the process since we already have a single-digit number. diSum(358) → 7 diSum(98765) → 8 diSum(9246) → 3 ...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: 390
Copyright Nick Parlante 2017 - privacy