DigitHelm

Digital Root Calculator

Calculate the digital root (iterated sum of digits), additive persistence, Harshad check, and multiplicative digital root for any integer up to 300 digits.

Supports integers up to 300 digits. Spaces and underscores are ignored.

Enter = calculate · Esc = reset

What Is the Digital Root Calculator?

This calculator finds the digital root of any integer, the single digit obtained by repeatedly replacing a number with the sum of its digits until only one digit remains. It shows every intermediate step, the number of iterations (additive persistence), the direct formula result for instant verification, and whether the number is a Harshad (Niven) number.

  • Arbitrarily large integers, supports inputs up to 300 digits, far beyond JavaScript's safe integer limit, using string-based digit arithmetic.
  • Additive persistence, shows exactly how many digit-sum reductions are needed; the number with the highest known persistence in base 10 is 88 (requiring 3 steps).
  • Formula verification, computes DR(n) = 1 + (n−1) mod 9 alongside the iterative result so you can confirm both methods agree.
  • Harshad number check, verifies whether n is divisible by its own digit sum S(n); Harshad numbers are a fascinating subset of every integer sequence.
  • Multiplicative digital root, a collapsible section shows the result of repeatedly multiplying digits instead of adding them.
  • Pattern grid, a 1–90 grid color-coded by digital root makes the mod-9 structure instantly visible; your result column is highlighted.

Formula

Digital Root, Direct Formula

DR(n) = 1 + (n − 1) mod 9   (for n > 0)

DR(0) = 0   (special case)

DR(n) = n mod 9   if n mod 9 ≠ 0, else DR(n) = 9   (for n > 0)

Additive Persistence

AP(n) = number of digit-sum reductions until a single digit remains

AP(n) = 0 if n is already a single digit (0–9)

Harshad (Niven) Number Condition

n is Harshad  ⟺  n mod S(n) = 0

where S(n) = sum of all decimal digits of n

Digital Root in Base b

DR_b(n) = 1 + (n − 1) mod (b − 1)   (for n > 0)

Base 10: mod 9  ·  Base 2: mod 1 (trivial)  ·  Base 8: mod 7  ·  Base 16: mod 15

SymbolNameDescription
nInput integerThe non-negative integer whose digital root you want to find
S(n)Sum of digitsThe sum of all decimal digits of n, also called the digit sum
DR(n)Digital rootThe single digit (0–9) reached by iterating digit sums; always equal to n mod 9 (with 0→9 fix)
AP(n)Additive persistenceHow many times you must apply the digit-sum operation before reaching a single digit
mod 9Modulo 9DR and mod 9 are the same mathematical operation with a different convention for multiples of 9

Key properties of digital roots

DR(a + b) = DR(DR(a) + DR(b))  (additive compatibility)

DR(a × b) = DR(DR(a) × DR(b))  (multiplicative compatibility)

DR(n) = 9  ⟺  9 ∣ n and n > 0

DR(n) = 0  ⟺  n = 0

DR(10ᵏ) = 1 for all k ≥ 0  (powers of 10 always have DR = 1)

DR(repunit Rₙ) = DR(n mod 9)  (repunit = 111…1 with n ones)

How to Use

  1. 1
    Enter any non-negative integer: Type a number of any size into the input field. Spaces and underscores are ignored, so 1_000_000 and 1 000 000 both work.
  2. 2
    Press Enter or click Calculate: The calculator shows the digital root, digit sum, additive persistence, formula result, and Harshad check immediately.
  3. 3
    Read the step-by-step trace: Each reduction step is shown with its digits and their sum. The last step's result is the digital root.
  4. 4
    Check the formula verification: DR(n) = 1 + (n−1) mod 9 is computed independently. Both methods should give the same answer, if they do, a green ✓ appears.
  5. 5
    Explore multiplicative digital root: Click the "Multiplicative digital root" panel to see what happens when digits are multiplied instead of added. A single zero digit immediately collapses the result to 0.
  6. 6
    Explore the pattern grid: The 1–90 grid shows all numbers colour-coded by digital root. Every column has a single digital root, this is the visual form of n mod 9.
  7. 7
    Reset and try another: Click Reset (or press Esc) to clear the form. Your last input is saved in localStorage and restored when you return.

Example Calculation

Example 1, Digital root of 9875

Input: n = 9875

Step 1: S(9875) = 9 + 8 + 7 + 5 = 29

Step 2: S(29) = 2 + 9 = 11

Step 3: S(11) = 1 + 1 = 2 ← single digit

Digital root = 2   (additive persistence = 3)

Formula check: 1 + (9875 − 1) mod 9 = 1 + 9874 mod 9 = 1 + 1 = 2 ✓

Harshad check: 9875 ÷ 29 = 340.517… → NOT a Harshad number

Example 2, Digital root of 9999 (multiple of 9)

Input: n = 9999

Step 1: S(9999) = 9 + 9 + 9 + 9 = 36

Step 2: S(36) = 3 + 6 = 9 ← single digit

Digital root = 9   (additive persistence = 2)

Formula check: 1 + (9999 − 1) mod 9 = 1 + 9998 mod 9 = 1 + 8 = 9 ✓

9999 ÷ 36 = 277.75 → NOT Harshad. But 9999 ÷ 9 = 1111 (9 | 9999 ✓)

Example 3, Harshad number: 18

Input: n = 18

Step 1: S(18) = 1 + 8 = 9 ← single digit

Digital root = 9   (additive persistence = 1)

Harshad check: 18 ÷ 9 = 2 (exact) → ✓ Harshad number

Other Harshad numbers near 18: 10, 12, 18, 20, 21, 24, 27, 30…

nDigit sumStepsDigital rootHarshad?
9909Yes (9÷9=1)
18919Yes (18÷9=2)
100101Yes (100÷1=100)
3651425No (365÷14≈26.07)
9875 ★2932No (9875÷29≈340.5)
999994529Yes (99999÷45=2222.2…) No

Understanding Digital Root

What Is a Digital Root?

The digital root of a positive integer is the single-digit value (1–9) obtained by summing its digits, then summing those digits, and repeating until only one digit remains. For zero the digital root is 0 by convention. The process always terminates: even a 1000-digit number has a digit sum no greater than 9000, which collapses to a two-digit number in one more step, then to a single digit on the third step at most.

The direct formula skips the iteration entirely: DR(n) = 1 + (n − 1) mod 9 for n > 0, and 0 for n = 0. This equivalence holds because every time you sum the digits of a number you subtract a multiple of 9 from it, the process is exactly equivalent to computing the remainder after dividing by 9, with the special convention that a remainder of 0 gives digital root 9 (not 0).

Why the Formula Works, Casting Out Nines

The key insight is that any two-digit number ab = 10a + b can be written as 9a + (a + b). So ab and its digit sum (a + b) differ by a multiple of 9. Applying this repeatedly, any integer and its digital root are congruent modulo 9. The sequence of digit sums is monotonically decreasing (for n ≥ 10) and bounded below by 1, so it must converge to a single digit in finitely many steps.

This relationship between a number and its digit sum is the foundation of casting out nines, one of the oldest arithmetic verification methods. To check whether a multiplication is correct:

  • Compute the digital root of each factor and the stated product.
  • If the product of the two digital roots (reduced to a single digit) does not equal the digital root of the product, the calculation contains an error.
  • If they match, the calculation is probably correct (though not certainly, some errors cancel out).
  • Example: 123 × 45 = 5535. DR(123)=6, DR(45)=9, DR(6×9)=DR(54)=9. DR(5535)=9. Checks out.

Additive Persistence

The additive persistence is the number of digit-sum operations needed to reach the digital root. For single-digit numbers it is 0. For most numbers it is 1 or 2. Finding numbers with high persistence in a given base is a studied problem in recreational mathematics.

PersistenceSmallest base-10 exampleNotes
00–9Already a single digit
110 → 11+0 = 1
219 → 10 → 11+9=10, then 1+0=1
3199 → 19 → 10 → 1Three steps
419999999999999999999999 → …Smallest 4-persistence number; 23 nines

It is an open question whether any number in base 10 has additive persistence greater than 11. This is in stark contrast to multiplicative persistence, where the smallest number with persistence 11 is 277777788888899 (a known result).

Harshad (Niven) Numbers

A Harshad number (named by D. R. Kaprekar from the Sanskrit for "great joy"; also called a Niven number) is a positive integer that is divisible by its digit sum. For example, 18 is Harshad because its digit sum is 9 and 18 ÷ 9 = 2 exactly. The Harshad numbers begin: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36…

  • Every single-digit number 1–9 is trivially Harshad (any number is divisible by itself).
  • Every multiple of 10 whose first digit is 1 (10, 100, 1000…) is Harshad, since digit sum = 1.
  • Not all multiples of 9 are Harshad, 9, 18, 27, 36 are, but 9999 is not (9999 ÷ 36 ≈ 277.75).
  • Runs of consecutive Harshad numbers can be long; there are 14 consecutive Harshad numbers starting at 1, 2, 3 (trivially).
  • The density of Harshad numbers in {1, …, N} tends to 0 as N → ∞, but they remain fairly common in practice.

Multiplicative Digital Root and Persistence

Instead of adding digits, you can multiply them and repeat until a single digit remains. This is the multiplicative digital root. The number of steps is the multiplicative persistence.

Any digit 0 immediately terminates the process since 0 × anything = 0. Digits 1 are neutral and can be thought of as filler. The hardest numbers to reduce have only digits 2–9. The current record holder (as of 2024) for highest multiplicative persistence is 277777788888899 with persistence 11.

Digital root vs digit sum, a common confusion

The digit sum S(n) is the single application of adding all digits: S(9875) = 29. The digital root DR(n) is the result of iterating digit sums until a single digit is reached: DR(9875) = 2. The two are equal only when S(n) is already a single digit (e.g. S(12) = 3 = DR(12)).

Digital Roots in Other Bases

The concept generalises to any integer base b: DR_b(n) = 1 + (n − 1) mod (b − 1) for n > 0. In base 16 (hexadecimal) the "casting out fifteens" rule applies, and the digital root of a hex number ranges from 1 to F (1 to 15). In base 2 (binary) every positive integer has digital root 1 (since (b − 1) = 1 and any number mod 1 = 0, giving 0 + 1 = 1), which means the concept is trivial in binary.

Applications in Computing and Checksums

The Luhn algorithm, used to validate credit card numbers, IMEI numbers, and other identifiers, is a variation of digit-sum arithmetic. It doubles every other digit, sums all digits, and checks divisibility by 10. While not literally the digital root, it exploits the same modular arithmetic that makes digit sums meaningful.

ISBN-10 and ISBN-13 checksums also involve digit sums with weighted positions. Understanding digital roots provides intuition for why these checksums catch certain types of transcription errors (swapped adjacent digits, single-digit errors) while missing others (swaps of digits that differ by 9).

Frequently Asked Questions

What is a digital root and what does it tell you about a number?

The digital root is the result of iterating the digit-sum operation until a single digit (0–9) remains.

  • It tells you which mod-9 equivalence class a number belongs to.
  • DR(n) = 9 means n is a positive multiple of 9.
  • DR(n) = 0 means n = 0 (the only non-negative number with DR = 0).
  • DR(a+b) = DR(DR(a)+DR(b)), digital roots are compatible with arithmetic operations.

Practically: digital roots are used in arithmetic verification (casting out nines), Harshad number classification, and certain puzzle games involving digit sums.

Why does every positive multiple of 9 have a digital root of 9?

The formula DR(n) = n mod 9 (with 0 mapped to 9 for positive n) makes this clear: any positive multiple of 9 satisfies n mod 9 = 0, which is remapped to 9.

Iterative explanation:

  • 18 → 1+8 = 9 ✓
  • 99 → 9+9 = 18 → 1+8 = 9 ✓
  • 999 → 27 → 9 ✓
  • Any n = 9k: digit sum ≡ 0 mod 9, so it is itself a multiple of 9, reducing to 9 eventually.

This is why casting out nines uses 9 as the modulus, multiples of 9 always "collapse" to 9 in digital-root arithmetic.

What is a Harshad number and how is it different from a number with digital root 9?

Two different conditions:

  • Digital root = 9: n is divisible by 9 (i.e. 9 | n).
  • Harshad number: n is divisible by its digit sum S(n) (not necessarily 9).

The overlap and differences:

  • 18: DR=9, Harshad (18÷9=2), both conditions hold.
  • 12: DR=3, Harshad (12÷3=4), Harshad but DR≠9.
  • 99: DR=9, NOT Harshad (99÷18≈5.5), DR=9 but not Harshad.
  • 10: DR=1, Harshad (10÷1=10), Harshad with DR=1.

What is the maximum possible digital root?

Digital roots are always in the range 0–9, by definition, since that's what "a single decimal digit" means.

  • Minimum for positive integers: 1 (e.g., 1, 10, 100, 1000)
  • Maximum: 9 (e.g., 9, 18, 27, 99, 999)
  • The only non-negative integer with DR = 0 is n = 0 itself
  • Powers of 10 always have DR = 1 since 1+0+0+… = 1

How does casting out nines work as an arithmetic check?

Casting out nines exploits the identity DR(a+b) = DR(DR(a)+DR(b)):

  • To check 123 + 456 = 579: DR(123)=6, DR(456)=6, DR(6+6)=DR(12)=3. DR(579)=3. Checks out ✓
  • To check 123 × 45 = 5535: DR(123)=6, DR(45)=9, DR(6×9)=DR(54)=9. DR(5535)=9. ✓
  • If 123 × 45 = 5530 (wrong): DR(5530)=4 ≠ 9 → error detected ✓
  • Limitation: swapping digits 27 → 72 preserves DR (both =9), so some errors are missed.

Despite its limitations, casting out nines was the standard manual arithmetic checker before calculators and remains a useful mental check for detecting most errors.

What is additive persistence and which numbers have the highest persistence?

Additive persistence (AP) = how many digit-sum steps reach a single digit:

  • AP = 0: any single digit (0–9)
  • AP = 1: e.g. 10 (1+0=1), 99 (9+9=18? No, 99→18→9, so AP=2). Actually 10→1 (AP=1)
  • AP = 2: e.g. 19 (1+9=10→1) or 99 (9+9=18→9)
  • AP = 3: smallest is 199 (199→19→10→1)
  • AP = 4+: requires very large numbers with many 9s

The sequence of smallest numbers with persistence 0,1,2,3,4,… is an interesting problem in recreational mathematics studied by Neil Sloane and others (OEIS A006050).

How does the digital root work for very large numbers?

Large numbers pose no problem for digital root computation:

  • The direct formula DR(n) = 1+(n−1) mod 9 only requires n mod 9, computable in a single pass through the digits.
  • This calculator uses BigInt and string-based digit arithmetic to handle up to 300-digit integers exactly.
  • The iterative approach (sum digits repeatedly) also terminates quickly: a 300-digit number has digit sum at most 2700, which is a 4-digit number.
  • Even a trillion-digit number would reduce to a single digit in about 3 steps.

Does this calculator save my inputs between visits?

Yes, your last entered number is saved to localStorage automatically:

  • The input is saved after each successful calculation
  • It is restored the next time you open this page
  • All data stays in your browser, no server communication
  • All computations run live, locally, in your browser, powered by digithelm.com

Press Reset or Esc to clear the form and the saved state.

Related Calculators