Digital root


The digital root of a natural number in a given number base is the 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 be a natural number. For base, we define the digit sum to be the following:
where is the number of digits in the number in base, and
is the value of each digit of the number. A natural number is a digital root if it is a fixed point for, which occurs if.
All natural numbers are preperiodic points for, regardless of the base. This is because if, then
and therefore
because.
If, then trivially
Therefore, the only possible digital roots are the natural numbers, and there are no cycles other than the fixed points of.

Example

In base 12, 8 is the multiplicative digital root of the base 10 number 3110, as for
This process shows that 3110 is 1972 in base 12. Now for
, showing 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 in the following ways:

Congruence formula

The formula in base is:
or,
In base 10, the corresponding sequence is.
The digital root is the value modulo because and thus so regardless of position, the value is the same – – which is why digits can be meaningfully added. Concretely, for a three-digit number
To obtain the modular value with respect to other numbers, one can take weighted sums, where the weight on the -th digit corresponds to the value of modulo. In base 10, this is simplest for 2, 5, and 10, where higher digits vanish, 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.
Also of note is the modulus : since and thus taking the alternating sum of digits yields the value modulo.

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 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. Likewise, in base 10 the digital root of 2035 is 1, which means that. If a number produces a digital root of exactly, then the number is a multiple of.
With this in mind the digital root of a positive integer may be defined by using floor function, as

Properties

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, and then that 1 + 8 = 9.
There is no limit to the additive persistence of a number in a number base.. The smallest numbers of additive persistence 0, 1,... in base 10 are:
The next number in the sequence is 2 × 102×/9 − 1. 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 -> int:
total = 0
while x > 0:
total = total +
x = x // b
return total
def digital_root -> int:
seen = set
while x not in seen:
seen.add
x = digit_sum
return x
def additive_persistence -> int:
seen = set
while x not in seen:
seen.add
x = digit_sum
return len - 1

In popular culture

Digital roots are used in Western numerology, but certain numbers deemed to have occult significance 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.