ine@mit software and mathematics

24Jun/111

The Rule of 9′s

An accounting professor I know shared an interesting heuristic with me today called "The Rule of 9's." The trick is that if you're adding up a ledger of numbers and the difference between the result and what you expected is a multiple of 9, it's highly likely that you've swapped the digits of two numbers (eg. written 382 as 328). So the claim was that any time you swapped the digits of a number, the difference between it and the original would be divisible by 9.

This sounded like a really interesting proof, and I guessed it was related to our base 10 numbering system. So, let x and y be the two digits which will be swapped, B be the base of the numbering system, n be the exponent of the base at x and n - d be the exponent of the base at y.

The difference between the number and its modified form will be the following:

xBn + yBn-d - (yBn + xBn-d)

Bn-d(Bd(x - y) + (y - x))

Bn-d((Bd) - 1)(x - y)

now the result is clearly divisible by Bd - 1. For our number system, B = 10 and so the result is 10d-1. So a transposition of 1 will be divisible by 10-1 = 9. Hence the rule of nines! A transposition of 2 will be divisible by 99, etc. And in general a transposition of d in base 10 is divisible by 10d-1.

Linearity also means that even if you have a lot of swapped digits, the final result will still be divisible by 9. Of course, there might be no digits swapped and the error difference is still divisible by 9, but it's less likely.

So I thought that was pretty cool, and a really nifty proof.

Comments (1) Trackbacks (0)
  1. This is a good one to know the next time I’m adding long sets of numbers for an audit. I’ll add it to my grab-bag of useful tricks!


Leave a comment

No trackbacks yet.