1.Divisibility and digit sums
We write when for some integer . Divisibility is preserved by sums and differences. If and , then and , so and force and . This closure is what makes divisibility tests work: you only need the remainders of the pieces of a number, not the number itself.
The test for comes from one observation, , so . Writing and reducing each power of gives . So and its digit sum leave the same remainder on division by . For example , and . The same argument with gives the test for .
The test for uses . Each digit in an odd position gets weight and each digit in an even position gets weight , so and its alternating digit sum agree mod . For , the alternating sum is , as it must be.
Tests for and depend only on the last few digits, because and . More generally, is a multiple of and , so the last digits decide divisibility by and alone.
Digit problems are counting problems about strings of digits. Write the number as , translate each condition into a statement about neighbouring digits, and count with the multiplication principle. A condition such as “the digits are strictly increasing” is really a choice of a set: a strictly increasing string is determined by the set of digits it uses, so -digit strings from with this property correspond to subsets. Leading zeros must be handled separately, since a string starting with is not a -digit number.
- means for some integer ; if and then
- , so exactly when divides the digit sum
- Divisibility by or depends only on the last digits
Spot it: The problem asks whether a number is a multiple of something, asks for the remainder of a very long number, or counts digit strings that satisfy a digit condition.
- Treating the digit sum as the remainder itself; it is only congruent to modulo , and can be much larger than
- Checking only the last digit for divisibility by or , which needs the last two or three digits
- Counting a digit string with a leading zero as if it were a number with that many digits
Find the remainder when the -digit number consisting of sevens is divided by .