Alternating digit sum

ID: alternating-digit-sum

The alternating digit sum of a nonnegative integer in radix is
with a positive sign on the units digit. Starting the signs from the opposite end can change the overall sign, so the convention should be stated.
Because , the positional expansion gives . This proves a divisibility test: divides the number exactly when it divides its alternating digit sum. In decimal notation, has alternating sum and equals .
The rule differs from the ordinary digit sum test modulo , which instead uses . Both follow from the same modular arithmetic principle of replacing the radix by its residue before evaluating the digit polynomial.

New to topics? Read the docs here!