“Casting out nines” is a trick for determining the remainder when a number is divided by nine. Just add the digits of the number together. For example, what’s the remainder when 3896 is divided by 9? The same as when 3+8+9+6 = 26 is divided by 9. We can apply the same trick again: 2+6 = 8, so the remainder is 8.
Casting out nines works because 9 is one less than 10, i.e. one less than the base we use to represent numbers. The analogous trick would work casting out (b-1)’s in base b. So you could cast out 7’s in base 8, or F‘s in base 16, or Z’s in base 36.
Why can you cast out (b-1)’s in base b? First, a number written is base b is a polynomial in b. If the representation of a number x is anan-1 … a1a0 then
x = anbn + an-1bn-1 + … + a1b + a0.
bm – 1 = (b – 1)(bm-1 + bm-2 + … + 1)
it follows that bm leaves a remainder of 1 when divided by b – 1. So ambm leaves the same remainder as am when divided by b – 1. If follows that
anbn + an-1bn-1 + … + a1b + a0
has the same remainder when divided by b – 1 as
an + an-1 + … + a1 + a0
does when it is divided by b – 1.