Digital root

The digital root (also repeated digital sum) of a natural number in a given radix is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached.
Formal definition.
Let formula_1 be a natural number. For base formula_2, we define the digit sum formula_3 to be the following:
where formula_5 is the number of digits in the number in base formula_6, and
is the value of each digit of the number. A natural number formula_1 is a digital root if it is a fixed point for formula_9, which occurs if formula_10. 
All natural numbers formula_1 are preperiodic points for formula_9, regardless of the base. This is because if formula_13, then
and therefore
because formula_2.
If formula_17, then trivially 
Therefore, the only possible digital roots are the natural numbers formula_19, and there are no cycles other than the fixed points of formula_19.
Example.
In base 12, 8 is the additive digital root of the base 10 number 3110, as for formula_21
This process shows that 3110 is 1972 in base 12. Now for formula_27
shows that 19 is 17 in base 12. And as 8 is a 1-digit number in base 12,
Direct formulas.
We can define the digit root directly for base formula_2 formula_33 in the following ways:
Congruence formula.
The formula in base formula_6 is:
or,
In base 10, the corresponding sequence is .
The digital root is the value modulo formula_37 because formula_38 and thus formula_39 so regardless of position, the value formula_40 is the same – formula_41 – which is why digits can be meaningfully added. Concretely, for a three-digit number formula_42
To obtain the modular value with respect to other numbers formula_1, one can take weighted sums, where the weight on the formula_45-th digit corresponds to the value of formula_46 modulo formula_1. In base 10, this is simplest for 2, 5, and 10, where higher digits vanish (since 2 and 5 divide 10), which corresponds to the familiar fact that the divisibility of a decimal number with respect to 2, 5, and 10 can be checked by the last digit (even numbers end in 0, 2, 4, 6, or 8). 
Also of note is the modulus formula_48: since formula_49 and thus formula_50 taking the "alternating" sum of digits yields the value modulo formula_51.
Using the floor function.
It helps to see the digital root of a positive integer as the position it holds with respect to the largest multiple of formula_37 less than the number itself. For example, in base 6 the digital root of 11 is 2, which means that 11 is the second number after formula_53. Likewise, in base 10 the digital root of 2035 is 1, which means that formula_54. If a number produces a digital root of exactly formula_37, then the number is a multiple of formula_37.
With this in mind the digital root of a positive integer formula_1 may be defined by using floor function formula_58, as
Additive persistence.
The additive persistence counts how many times we must sum its digits to arrive at its digital root. 
For example, the additive persistence of 2718 in base 10 is 2: first we find that 2 + 7 + 1 + 8 = 18, then that 1 + 8 = 9. 
There is no limit to the additive persistence of a number in a number base formula_6. Proof: For a given number formula_1, the persistence of the number consisting of formula_1 repetitions of the digit 1 is 1 higher than that of formula_1. The smallest numbers of additive persistence 0, 1, ... in base 10 are:
The next number in the sequence (the smallest number of additive persistence 5) is 2 × 102×(1022 − 1)/9 − 1 (that is, 1 followed by 2 222 222 222 222 222 222 222 nines). For any fixed base, the sum of the digits of a number is proportional to its logarithm; therefore, the additive persistence is proportional to the iterated logarithm.
Programming example.
The example below implements the digit sum described in the definition above to search for digital roots and additive persistences in Python.
def digit_sum(x: int, b: int) -> int:
 total = 0
 while x > 0:
 total = total + (x % b)
 x = x // b
 return total
def digital_root(x: int, b: int) -> int:
 seen = set()
 while x not in seen:
 seen.add(x)
 x = digit_sum(x, b)
 return x
def additive_persistence(x: int, b: int) -> int:
 seen = set()
 while x not in seen:
 seen.add(x)
 x = digit_sum(x, b)
 return len(seen) - 1
In popular culture.
Digital roots are used in Western numerology, but certain numbers deemed to have occult significance (such as 11 and 22) are not always completely reduced to a single digit.
Digital roots form an important mechanic in the visual novel adventure game "Nine Hours, Nine Persons, Nine Doors".