Module 3.5 · Number Theory
Digits and bases
Digit problems look like puzzles, but they are really algebra and modular arithmetic in disguise. The trick is always to write the number out as a polynomial in its base, , and then use two facts: the digit sum controls the remainder mod , and digits are small, which gives tight bounds.
Base as a polynomial
A number written in base means
This representation exists and is unique: is forced to be , then repeat with . A number has exactly digits in base when , i.e. .
Problems like "" become polynomial equations in . Remember that every digit must be less than .
Digit sums and remainders
Digit sums
Let be the sum of the base- digits of . Then
In base : and alternating digit sum .
Why. , so every and . Similarly , so .
Two consequences you will use constantly:
- is always a multiple of .
- is small. A number below has digit sum at most . So in an equation like , you know is within or so of .
Carries
When you add two numbers digit by digit, each carry replaces in one column by in the next, so it lowers the total digit sum by :
For doubling, a digit produces a carry exactly when (and a carry never causes a second one, since ). So , where is the number of digits of that are at least . The same carry counting in base is the heart of Kummer's theorem in the -adic module.
Trailing zeros in base
The number of trailing zeros of in base is the largest with . For , that is the minimum over primes of , where is the exponent of in . For factorials, comes from Legendre's formula.
Worked example: An equation in the base
Is there a base in which ?
, so , , . But the digit is not allowed in base . So there is no such base. Always check the digit constraint.
Worked example: Digit algebra
A two-digit number is times the sum of its digits. What can it be?
. So the numbers are .
Worked example: Digit sum plus bounding
Find all with .
Mod : , so . Also has , so . The numbers from to are . Check: ✓, , . So only.
Worked example: How many digits
How many digits does have?
, so : it has digits.
Common mistake
The mod- trick only gives a necessary condition. It narrows the candidates; you still have to check each one, as in the example, where two of the three candidates failed.
Practice
Find the base for which .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Find the three-digit positive integer that equals times the sum of its digits.
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many zeros does end with when written in base ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Let denote the sum of the decimal digits of . How many positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
The number is formed by writing the integers from to in order. Find the remainder when is divided by .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many positive integers less than have no digit when written in base ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Let be the sum of the decimal digits of . How many positive integers satisfy ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2018 AIME I, Problem 2: a number with related digit patterns in three different bases.
- 2023 AIME II, Problem 2: the greatest integer below that is a palindrome in both base ten and base eight.