Digital Root and Casting Out Nines

Digital roots and the nines check, in any base.

  • Any base from 2 to 36
  • Nines and elevens
  • Errors that slip by
Soft clay beads gathered into small mounds of equal size on a rounded clay table, each mound beside one leftover bead, in gentle daylight.

The guide

A digit sum keeps the remainder: casting out nines, and why a pass is only a hint

Adding the digits of a number keeps its remainder after division by nine, which turns a long sum into a quick test. A failed test proves a mistake; a passed one proves nothing.

  • 6 root of 12,345, after two rounds
  • 1,396 lots of nine cast out of 12,565
  • 199 smallest number needing three rounds
  • 111 of 1 to 1,000 have root 9
  • 24,300 swaps the elevens check caught
Read the full guide Fold the guide 6 min · 11 sources

Take the number 2,946 and add its digits: 2 + 9 + 4 + 6 is 21. The Wikipedia article on casting out nines points out that 21 equals 2,946 minus 325 lots of nine. The digit sum has quietly removed 325 nines from the number and left the rest behind. That small fact is the whole trick.

Everything else is bookkeeping. If the digit sum keeps the remainder on division by nine, then a long calculation can be tested by working on the short remainders instead.

Why the digit sum keeps the remainder

Write a three-digit number as d2 times 100, plus d1 times 10, plus d0. In base 10 the number ten leaves a remainder of 1 when divided by nine, so a hundred leaves 1 as well, and so does every power of ten. The Digital root article gives this argument in general form. In base b, the number b is congruent to 1 modulo b minus 1, so every power of b is also congruent to 1, and each digit counts exactly once.

That is why a digit may sit in any position and still contribute only its own value to the remainder. The article on casting out nines shows the same thing as a subtraction. The number minus its digit sum equals a sum of terms like (10^i minus 1) times a digit, and each of those is a multiple of nine.

So the digit sum is smaller than the number (whenever the number has more than one digit) but has the same remainder on division by nine. Any number can be replaced by its digit sum without changing what you will learn about its divisibility by nine.

The same reasoning works in every base. In base 12 the stand-in divisor is eleven, in base 16 it is fifteen, and in base 2 it is one, which tells you nothing at all. That last case is worth remembering: the method needs a base with room to spare.

From one sum to the digital root

Once the digit sum is smaller, you can sum again, and again, until a single digit is left. That digit is the digital root. The Digital root article defines it exactly this way, with the example of 12,345: the digits add to 15, then 1 + 5 is 6. The root is 6, reached in two rounds.

The count of rounds has a name, additive persistence, and the Persistence of a number article gives 2718 as a case with persistence 2. The sum goes 18, then 9. Persistence grows very slowly. The smallest numbers needing 1, 2 and 3 rounds are 10, 19 and 199, and the next one is far larger: the Digital root article lists a 23-digit number, 19 followed by 21 nines. The tool confirms that this number needs four rounds. It does not check that it is the smallest, so that part rests on the article alone.

A second worked case shows how many nines are removed. The number 12,565 gives 19, then 10, then 1. The Casting out nines article subtracts the final root and divides by nine: (12,565 minus 1) divided by 9 is 1,396 lots of nine cast out.

You do not have to run the rounds. The Digital root article gives a direct formula: for n above zero in base b, the root is 1 + ((n minus 1) mod (b minus 1)). A floor form, n minus (b minus 1) times the floor of (n minus 1) over (b minus 1), says the same thing. Both agree with the repeated sum for every n from 0 to 100,000 in base 10, which the page checks itself.

One detail trips people up. A multiple of nine has digital root 9, not 0, because the root is a digit reached by summing, and a positive number never sums down to 0. The remainder is 0, but the root is 9. Of the numbers from 1 to 1,000, exactly 111 have root 9.

Testing a sum by hand

The check itself is short. Replace each number in a calculation by its digital root, do the same operation on the roots, and compare with the root of the answer. The Modular arithmetic article explains why this is allowed: congruence is compatible with addition, subtraction and multiplication, so reducing first and calculating after gives the same remainder as calculating first.

Here is a worked example you can reproduce on the page. Multiply 12,345 by 6,789. The roots are 6 and 3. Their product is 18, whose root is 9. The true product is 83,810,205, and its digits add to 9 once more, so the check passes.

For subtraction, take the difference of the roots, and add nine if it goes negative. The one exception is a result of zero: it stays zero only when the true difference is itself zero, and otherwise it is written as 9. Division can be checked by running the multiplication backwards, as the Casting out nines article shows.

The alternating digit sum gives a second, independent test. In base b it measures the value modulo b + 1, because b is congruent to minus 1 there, so the powers of b alternate between 1 and minus 1. In base 10 this is the elevens check, and the Divisibility rule article gives the matching rule for eleven: 918,082 gives 9 minus 1 plus 8 minus 0 plus 8 minus 2, which is 22, a multiple of eleven.

Apply it to the same product. The alternating sums of 12,345 and 6,789 are 3 and 2, and 3 times 2 is 6. The alternating sum of 83,810,205, taken modulo 11, is also 6, so the elevens check passes too.

What a passed check cannot tell you

Now change one thing. Swap the last two digits of the product, so that 83,810,205 becomes 83,810,250. The digits still add to 9 once more, so the nines check says nothing is wrong. The answer is wrong, and the nines check cannot tell.

That is not bad luck. The Casting out nines article states that the method cannot see an error in a calculation of 5 times 7 that produced 8, 17 or 26, because every such result is congruent to 8 modulo nine. The correct answer 35 also has root 8, so none of them can be told apart from it. The same article adds that two unequal numbers share a root about one time in nine.

The Transcription error article says the difference caused by a transposition is always divisible by nine, and gives (72 minus 27) divided by 9 equals 5. The reason is simple. Swapping neighbouring digits x and y at place i changes a number by (x minus y) times b^i times (b minus 1), always a multiple of b minus 1. This page derives that formula rather than copying it, and tests it: across every neighbour swap in every four-digit number from 1000 to 9999, all 27,000 swaps left the digital root unchanged.

The elevens check does better here. In the same range, it caught 24,300 of the 24,300 swaps of two unequal neighbouring digits. In the swapped product above, the alternating sum modulo 11 is 7 instead of 6, so the elevens check raises the alarm.

Neither test is complete. A mistake that changes the answer by a multiple of nine slips past the nines check, and a multiple of eleven slips past the elevens check. A mistake that changes it by a multiple of ninety-nine slips past both. Passing both checks makes a mistake less likely, never impossible.

Check-digit systems are built differently. The Luhn algorithm article says it detects almost all transpositions of adjacent digits, with the exception of 09 and 90, because it doubles every second digit instead of simply adding them all.

The logic runs one way only. A mismatch is a proof: if the roots disagree, the calculation is wrong, with no exception, since correct calculations always give equal roots. A match is a hint. You may trust it a little, and you should never write it down as a verification.

The method also says nothing about where the mistake is, and it does not work on fractions. It has no view of other checks such as casting out sevens. It is a fast filter for arithmetic that was done by hand.

Long numbers need no special care once the sum is done in one pass. The page reads up to 1,000 digits into a BigInt, which the MDN article describes as a way to hold integers beyond the safe range of ordinary numbers, and it writes results in any base from 2 to 36 using the radix argument of toString that the MDN article documents. The heavy self-checks run in a worker, as the Web Workers article describes, so the page stays responsive.

Sources

Every source consulted for this guide. Links checked November 10, 2026.

  1. Digital root - Wikipedia Wikipedia (CC BY-SA 4.0)
  2. Casting out nines - Wikipedia Wikipedia (CC BY-SA 4.0)
  3. Digit sum - Wikipedia Wikipedia (CC BY-SA 4.0)
  4. Persistence of a number - Wikipedia Wikipedia (CC BY-SA 4.0)
  5. Divisibility rule - Wikipedia Wikipedia (CC BY-SA 4.0)
  6. Transcription error - Wikipedia Wikipedia (CC BY-SA 4.0)
  7. Luhn algorithm - Wikipedia Wikipedia (CC BY-SA 4.0)
  8. Modular arithmetic - Wikipedia Wikipedia (CC BY-SA 4.0)
  9. BigInt - JavaScript | MDN MDN Web Docs (CC BY-SA 2.5 or later)
  10. BigInt.prototype.toString() - JavaScript | MDN MDN Web Docs (CC BY-SA 2.5 or later)
  11. Web Workers API - Web APIs | MDN MDN Web Docs (CC BY-SA 2.5 or later)