about | help | code help+videos | done | prefs |
We define the digital root of a nonnegative integer n as follows: Let s be the sum of the digits in n. If s is a one-digit number, then s is the digital root of n. Otherwise, the digital root of n is equal to the digital root of s. For example: The digital root of 3452 is 5. (3+4+5+2 = 14 --> 1+4 = 5) The digital root of 397 is 1. (3+9+7 = 19 --> 1+9 = 10 --> 1+0 = 1) Find and return the digital root of n. digitalRootAP(0) → 0 digitalRootAP(3452) → 5 digitalRootAP(397) → 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: 250
Copyright Nick Parlante 2017 - privacy