RosettaCodeData/Task/Digital-root/00DESCRIPTION

24 lines
1.2 KiB
Plaintext

The digital root, <math>X</math>, of a number, <math>n</math>, is calculated:
: find <math>X</math> as the sum of the digits of <math>n</math>
: find a new <math>X</math> by summing the digits of <math>X</math>, repeating until <math>X</math> has only one digit.
The additive persistence is the number of summations required to obtain the single digit.
The task is to calculate the additive persistence and the digital root of a number, e.g.:
:<math>627615</math> has additive persistence <math>2</math> and digital root of <math>9</math>;
:<math>39390</math> has additive persistence <math>2</math> and digital root of <math>6</math>;
:<math>588225</math> has additive persistence <math>2</math> and digital root of <math>3</math>;
:<math>393900588225</math> has additive persistence <math>2</math> and digital root of <math>9</math>;
The digital root may be calculated in bases other than 10.
;See:
* [[Casting out nines]] for this wiki's use of this procedure.
* [[Digital root/Multiplicative digital root]]
* [[Sum digits of an integer]]
* [[oeis:A010888|Digital root sequence on OEIS]]
* [[oeis:A031286|Additive persistence sequence on OEIS]]
* [[Iterated digits squaring]]
<br><br>