Math Core

Module 3.5 · Number Theory

Bases and digits

Base problems on the AMC 10 and 12 go well past converting numbers. You'll solve for an unknown base, test divisibility in another base, convert repeating "decimals" in base bb, count digits of enormous numbers, and untangle numbers whose digits are related in two different bases. All of it rests on one idea: a string of digits is a polynomial in the base.

Digits are a polynomial

dk‾ dk−1‾⋯d1‾ d0‾\underline{d_k}\,\underline{d_{k-1}} \cdots \underline{d_1}\,\underline{d_0} in base bb means

dkbk+dk−1bk−1+⋯+d1b+d0,0≤di≤b−1.d_k b^k + d_{k-1} b^{k-1} + \dots + d_1 b + d_0, \qquad 0 \le d_i \le b - 1.

When the base is unknown, this turns a digit equation into an ordinary polynomial equation in bb. Don't forget the hidden condition: every digit must be less than bb.

Divisibility in base bb

Since b≡1(modb−1)b \equiv 1 \pmod{b - 1}, every power of bb is ≡1\equiv 1, so a number is congruent to its digit sum modulo b−1b - 1. Since b≡−1(modb+1)b \equiv -1 \pmod{b+1}, powers of bb alternate 1,−1,1,…1, -1, 1, \dots, so a number is congruent to its alternating digit sum (starting from the units digit) modulo b+1b + 1. These are the base-bb versions of the tests for 99 and 1111.

Base-b facts

  • dk‾⋯d0‾\underline{d_k} \cdots \underline{d_0} in base bb equals dkbk+⋯+d1b+d0d_k b^k + \dots + d_1 b + d_0, with each di≤b−1d_i \le b - 1.
  • Modulo b−1b - 1, a number is congruent to its digit sum. Modulo b+1b + 1, it is congruent to its alternating digit sum.
  • A positive integer NN has kk digits in base bb exactly when bk−1≤N<bkb^{k-1} \le N \lt b^k.
  • A repeating block 0.d1d2⋯dk‾0.\overline{d_1 d_2 \cdots d_k} in base bb equals d1‾⋯dk‾ (base b)bk−1\dfrac{\underline{d_1} \cdots \underline{d_k}\ (\text{base } b)}{b^k - 1}.

The last fact works just like 0.36‾=36990.\overline{36} = \dfrac{36}{99} in base ten: multiplying by bkb^k shifts one full block left, and subtracting the original cancels the tail.

Counting digits of huge numbers

To count base-ten digits of something like 450⋅5964^{50} \cdot 5^{96}, pair up 22s and 55s into 1010s: 2100⋅596=24⋅1096=16⋅10962^{100} \cdot 5^{96} = 2^4 \cdot 10^{96} = 16 \cdot 10^{96}, which has 2+96=982 + 96 = 98 digits. For powers of 22 in base 88 or 1616, group the exponent: 2100=2⋅8332^{100} = 2 \cdot 8^{33}, which lies between 8338^{33} and 8348^{34}.

Worked example: Solving for the base

In some base bb, 3×25b=111b3 \times 25_b = 111_b. Find bb.

3(2b+5)=b2+b+13(2b + 5) = b^2 + b + 1, so 6b+15=b2+b+16b + 15 = b^2 + b + 1 and b2−5b−14=0b^2 - 5b - 14 = 0, which factors as (b−7)(b+2)=0(b - 7)(b + 2) = 0. So b=7b = 7. The largest digit used is 55, and 5<75 \lt 7, so this is valid. Check: 257=1925_7 = 19, 3⋅19=57=49+7+1=11173 \cdot 19 = 57 = 49 + 7 + 1 = 111_7.

Worked example: A remainder in base 8

What is the remainder when 357183571_8 is divided by 77?

In base 88, a number is congruent to its digit sum modulo 77: 3+5+7+1=16≡2(mod7)3 + 5 + 7 + 1 = 16 \equiv 2 \pmod 7. The remainder is 22. (Check: 35718=1913=7⋅273+23571_8 = 1913 = 7 \cdot 273 + 2.)

Worked example: A repeating fraction in base 7

Write 0.36‾70.\overline{36}_7 as a fraction in lowest terms.

The block 367=3⋅7+6=2736_7 = 3 \cdot 7 + 6 = 27 repeats with length 22, so the value is 2772−1=2748=916\dfrac{27}{7^2 - 1} = \dfrac{27}{48} = \dfrac{9}{16}.

Worked example: Digits of a power

How many digits does 21002^{100} have when written in base 88?

2100=2⋅299=2⋅8332^{100} = 2 \cdot 2^{99} = 2 \cdot 8^{33}. So 833≤2100<8348^{33} \le 2^{100} \lt 8^{34}, and 21002^{100} has 3434 digits in base 88: a 22 followed by 3333 zeros.

Common mistake

After solving for a base, check the digits. The equation 23b×2=51b23_b \times 2 = 51_b gives 4b+6=5b+14b + 6 = 5b + 1, so b=5b = 5 algebraically. But a base-55 number can't contain the digit 55, so no base works. Also, bb must be an integer greater than 11; discard negative or fractional roots.

Practice

Practice 1

Write 20262026 in base 77. (Enter the digits as a number.)

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

How many digits does 450⋅5964^{50} \cdot 5^{96} have when written in base ten?

Practice 3

In some base bb, 46b×2=103b46_b \times 2 = 103_b. Find bb.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

What is the remainder when the base-six number 5432106543210_6 is divided by 77?

Practice 5

When 15\dfrac{1}{5} is written in base 33, it is a repeating fraction. What is it?

Practice 6

How many positive integers less than 729729 are palindromes when written in base 33?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

A positive integer NN has three digits a‾ b‾ c‾\underline{a}\,\underline{b}\,\underline{c} in base 66, and the same digits in reverse order, c‾ b‾ a‾\underline{c}\,\underline{b}\,\underline{a}, in base 1111. Find NN (in base ten).

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

What is the sum of the digits of 1040−202610^{40} - 2026 (written in base ten)?

Real contest practice