TylerRosen
4/6/2017 - 10:44 PM

How to get the digital root of a number

How to get the digital root of a number

To get the "digital root" of a number, you add all of the digits of that number. If the sum of the digits is between 0 and 9 (i.e. is one digit), that's the digital root. Otherwise, you add the sum of the digits of _that_  number and so on until the sum is between 0 and 9.
For example: 
the digital root of 9 is 9.
the digital root of 15 is 1 + 5 = 6
the digital root of 159 = 1 + 5 + 9 = 15 = 1 + 5 = 6
the digital root of 2155 = 2 + 1 + 5 + 5 = 13 = 1 + 3 = 4
Write a javascript function which will find the digital root of a given number, e.g.:
digitalRoot(9) = 9
digitalRoot(15) = 16
and so on.