Chapter

Digits, Bases and Decimal Periods

This module translates problems about digits, bases, repunits, and decimal periods into congruences, orders, and the Chinese remainder theorem.
Log in to track solved progress and bookmarks.

Theory

Key Idea

The digits of a number are coefficients of powers of the base. If the base is replaced by a convenient residue, the decimal or base-\(b\) representation becomes a congruence: modulo \(b-1\) the base is \(1\), modulo \(b+1\) it is \(-1\), and modulo \(10^k-1\) a block of \(k\) digits behaves like one digit.

Decimal periods have the same nature: if \((n,10)=1\), then the period length of a fraction with denominator \(n\) is the order of \(10\) modulo \(n\).

Basic Facts

  • If \(N=\overline{a_ra_{r-1}\ldots a_0}_b\), then \(N=a_rb^r+\cdots+a_1b+a_0\).
  • \(N\equiv a_0+a_1+\cdots+a_r \pmod{b-1}\).
  • \(N\equiv a_0-a_1+a_2-\cdots+(-1)^r a_r \pmod{b+1}\).
  • The last \(k\) decimal digits determine the number modulo \(10^k\).
  • If \((n,10)=1\), the period of \(\frac{a}{n}\) is the least \(h>0\) such that \(10^h\equiv1\pmod n\).
  • The repunit \(R_m=11\ldots1=\frac{10^m-1}{9}\) often reduces a problem to divisibility of \(10^m-1\).

When to Use This Method

Use it when the problem involves digit sums, last digits, several last digits, palindromes, repeated blocks, base-\(b\) notation, decimal periods, or numbers of the form \(111\ldots111\).

How to Recognise the Method

Look for these signals: the representation of a number matters more than its size; the number is split into blocks; divisibility of a repeated-digit number is requested; a fraction is written as \(0.\overline{a_1a_2\ldots a_r}\); one must find a period or construct final digits of a square.

Typical Mistakes

  • Confusing the number \(\overline{abc}\) with the product \(abc\).
  • Forgetting that digit blocks may have leading zeros.
  • Using decimal periods without checking \((n,10)=1\).
  • Dividing a congruence by \(9\) when the modulus is not coprime to \(9\).
  • Treating a digit-sum rule as a proof without writing the congruence for powers of the base.

Mini-Checklist

  • Write the number as a sum of digits times powers of the base.
  • Choose the modulus: \(b-1\), \(b+1\), \(10^k\), \(10^k-1\), or the period denominator.
  • Replace the base by a convenient residue.
  • For a decimal period, find the order of \(10\) modulo the denominator.
  • For last-digit constructions, use the Chinese remainder theorem.

Examples

Example 1. Digit Sum as a Congruence

The basic technique is to derive the divisibility rule instead of memorising it.

Problem. Let \(N=\overline{a_ra_{r-1}\ldots a_0}_{10}\). Prove that \(N\equiv a_0+a_1+\cdots+a_r\pmod9\).

Solution.

We have \(N=a_r10^r+\cdots+a_1\cdot10+a_0\). Since \(10\equiv1\pmod9\), we get \(10^i\equiv1\pmod9\) for all \(i\). Hence \(N\equiv a_r+\cdots+a_1+a_0\pmod9\).

Comment. In olympiad problems, the real tool is the congruence \(10\equiv1\), not the memorised school rule.

Example 2. Divisibility by 11

Here the base is replaced by \(-1\).

Problem. Prove that \(N=\overline{a_ra_{r-1}\ldots a_0}_{10}\) is divisible by \(11\) if and only if \(a_0-a_1+a_2-\cdots+(-1)^r a_r\) is divisible by \(11\).

Solution.

Since \(10\equiv-1\pmod{11}\), we have \(10^i\equiv(-1)^i\pmod{11}\). Substituting this into the decimal expansion gives the required congruence.

Comment. The alternating sum is not a digit trick; it is simply the substitution \(10\equiv-1\).

Example 3. Divisibility of Repunits

Repunits are best written as \(\frac{10^n-1}{9}\).

Problem. Prove that \(R_m\mid R_n\), where \(R_t=\frac{10^t-1}{9}\), if and only if \(m\mid n\).

Solution.

If \(m\mid n\), then \(10^m-1\mid10^n-1\), so \(R_m\mid R_n\).

Conversely, suppose \(R_m\mid R_n\). Then \(10^m-1=9R_m\) divides \(9R_n=10^n-1\). Write \(n=qm+r\), \(0\le r0\), then \(0<10^r-1<10^m-1\), a contradiction. Thus \(r=0\), so \(m\mid n\).

Comment. This example unlocks many problems about numbers \(111\ldots111\).

Example 4. When a Repunit Can Be Prime

The first hidden observation is that a composite exponent gives a factorisation.

Problem. Suppose the number consisting of \(k\) ones is prime. Prove that \(k\) is prime.

Solution.

If \(k=ab\), where \(a,b>1\), then

\[R_k=1+10+\cdots+10^{ab-1}=R_a\left(1+10^a+10^{2a}+\cdots+10^{a(b-1)}\right).\]

Both factors are greater than \(1\), so \(R_k\) is composite. Hence \(k\) cannot be composite.

Comment. We do not prove the converse: prime \(k\) does not imply prime \(R_k\).

Example 5. Period as an Order

This is the standard passage from decimal notation to a congruence.

Problem. Let \((n,10)=1\). Prove that the period length of \(\frac{a}{n}\) is the least \(h>0\) such that \(10^h\equiv1\pmod n\).

Solution.

In long division, each shift of the decimal point multiplies the current remainder by \(10\) modulo \(n\). A period of length \(h\) means that after \(h\) steps the remainder returns to the same value: \(a10^h\equiv a\pmod n\). After reducing the fraction, this is equivalent to \(10^h\equiv1\pmod n\).

Comment. In problems it is usually better to speak about the order of \(10\) than about the visible period digits.

Example 6. Periods of \(1/7\), \(1/13\), \(1/37\)

This example shows how periods are found through powers of \(10\).

Problem. Find the period lengths of \(\frac17\), \(\frac1{13}\), and \(\frac1{37}\).

Solution.

For \(7\): \(10\equiv3\), \(10^2\equiv2\), \(10^3\equiv6\), and \(10^6\equiv1\pmod7\); no smaller positive exponent works, so the period is \(6\).

For \(13\): \(10^3\equiv-1\pmod{13}\), hence \(10^6\equiv1\), and no smaller exponent gives \(1\); the period is \(6\).

For \(37\): \(10^3=1000\equiv1\pmod{37}\), while \(10\not\equiv1\) and \(10^2\not\equiv1\), so the period is \(3\).

Comment. The period of a fraction is an order computation, not a decimal expansion computation.

Example 7. Last Digits via CRT

Problems about final digits often split into moduli \(2^k\) and \(5^k\).

Problem. Find all residues \(x\pmod{100}\) such that \(x^2\equiv x\pmod{100}\).

Solution.

The condition is \(x(x-1)\equiv0\pmod{100}\). Since \(100=4\cdot25\), we need \(x\equiv0\) or \(1\pmod4\), and \(x\equiv0\) or \(1\pmod{25}\). The four combinations give \(0\), \(1\), \(25\), and \(76\) modulo \(100\).

Comment. This is how numbers arise whose square ends in the same digits.

Example 8. Blocks of \(k\) Digits

This tool is needed in stronger digit-sum problems.

Problem. Suppose \(M\) is divisible by \(10^k-1\). Prove that the sum of its decimal digits is at least \(9k\).

Solution.

Split \(M\) from right to left into blocks of \(k\) digits and add the blocks as ordinary integers. The result \(T\) is congruent to \(M\) modulo \(10^k-1\), because \(10^k\equiv1\pmod{10^k-1}\). Also, the digit sum of \(T\) is not greater than the digit sum of \(M\).

Repeating this operation, we eventually get a positive number below \(10^k\), still divisible by \(10^k-1\). It must be \(10^k-1\), whose digit sum is \(9k\). Therefore the original digit sum was at least \(9k\).

Comment. This is typical: a simple block idea becomes a strong estimate.

Problems

Problems

#11.1
#11.1

Digit Sum in Base \(b\)

Digits Grade 8 Grade 9 ★★☆☆☆

Let \(b\ge2\), and let \(N=\overline{a_ra_{r-1}\ldots a_0}_b\). Prove that \(N\equiv a_0+a_1+\cdots+a_r\pmod{b-1}\). Find all bases \(b>5\) for which \(\overline{312}_b\) is divisible by \(b-1\).

Details
Problem: NT-B2-M11-P001
Difficulty: Level 2 of 5
Tag: Digits
Grade: Grade 8, Grade 9
#11.2
#11.2

Alternating Digit Sum

Digits Grade 8 Grade 9 ★★☆☆☆

Prove the divisibility rule for \(11\) using the alternating digit sum. Then find all four-digit numbers of the form \(\overline{ab37}\) that are divisible by \(11\).

Details
Problem: NT-B2-M11-P002
Difficulty: Level 2 of 5
Tag: Digits
Grade: Grade 8, Grade 9
#11.3
#11.3

The Last Three Digits

Digits Grade 8 Grade 9 ★★☆☆☆

Prove that a decimal number is divisible by \(8\) if and only if the number formed by its last three digits is divisible by \(8\). Find all digits \(c\) for which \(\overline{45c2}\) is divisible by \(8\).

Details
Problem: NT-B2-M11-P003
Difficulty: Level 2 of 5
Tag: Digits
Grade: Grade 8, Grade 9
#11.4
#11.4

The Base as an Unknown

Digits Grade 8 Grade 9 ★★☆☆☆

Find all integer bases \(b>6\) for which the number \(\overline{31}_b\) is divisible by \(5\).

Details
Problem: NT-B2-M11-P004
Difficulty: Level 2 of 5
Tag: Digits
Grade: Grade 8, Grade 9
#11.5
#11.5

An Even-Length Palindrome

Digits Grade 8 Grade 9 ★★☆☆☆

Prove that every decimal palindrome with an even number of digits is divisible by \(11\).

Details
Problem: NT-B2-M11-P005
Difficulty: Level 2 of 5
Tag: Digits
Grade: Grade 8, Grade 9
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 230
#11.6
#11.6

When One Repunit Divides Another

Divisibility Grade 9 Grade 10 ★★★☆☆

Let \(R_t=\frac{10^t-1}{9}\). Prove that \(R_m\mid R_n\) if and only if \(m\mid n\).

Details
Problem: NT-B2-M11-P006
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#11.7
#11.7

Primality of a Repunit

Divisibility Grade 9 Grade 10 ★★★☆☆

The number \(R_k=11\ldots1\), consisting of \(k\) ones, is prime. Prove that \(k\) is prime.

Details
Problem: NT-B2-M11-P007
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 260
#11.8
#11.8

Repunits Divisible by \(37\)

Divisibility Grade 9 Grade 10 ★★★☆☆

Find all positive integers \(n\) for which the repunit \(R_n=11\ldots1\) with \(n\) ones is divisible by \(37\).

Details
Problem: NT-B2-M11-P008
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#11.9
#11.9

The Period of a Fraction

Modular Arithmetic Grade 9 Grade 10 ★★★☆☆

Let \(00\) such that \(10^h\equiv1\pmod n\).

Details
Problem: NT-B2-M11-P009
Difficulty: Level 3 of 5
Tag: Modular Arithmetic
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 348
#11.10
#11.10

Three Periods

Remainders Grade 9 Grade 10 ★★★☆☆

Find the period lengths of the decimal fractions \(\frac17\), \(\frac1{13}\), and \(\frac1{37}\).

Details
Problem: NT-B2-M11-P010
Difficulty: Level 3 of 5
Tag: Remainders
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 346
#11.11
#11.11

A Fraction Repeating Its Denominator

Digits Grade 9 Grade 10 ★★★☆☆

Find all positive integers \(n\) for which the decimal fraction \(\frac1n\) equals \(0.\overline{n}\), where the repeating block is the decimal notation of \(n\) itself.

Details
Problem: NT-B2-M11-P011
Difficulty: Level 3 of 5
Tag: Digits
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 262
#11.12
#11.12

Period Exactly Two

Divisibility Grade 9 Grade 10 ★★★☆☆

Find all \(n>1\), coprime to \(10\), for which the decimal expansion of \(\frac1n\) has period exactly \(2\).

Details
Problem: NT-B2-M11-P012
Difficulty: Level 3 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#11.13
#11.13

A Repeated Three-Digit Block

Digits Grade 9 Grade 10 ★★★★☆

Let \(a\ne0\), and let \(N=\overline{abcabc}\). Prove that \(N\) is divisible by \(7\), \(11\), and \(13\).

Details
Problem: NT-B2-M11-P013
Difficulty: Level 4 of 5
Tag: Digits
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 302
#11.14
#11.14

A Square with the Same Last Digits

Modular Arithmetic Grade 9 Grade 10 ★★★★☆

Find all two-digit endings \(x\) modulo \(100\) for which \(x^2\) ends in the same two digits as \(x\).

Details
Problem: NT-B2-M11-P014
Difficulty: Level 4 of 5
Tag: Modular Arithmetic
Grade: Grade 9, Grade 10
#11.15
#11.15

Infinitely Many Automorphic Numbers

Chinese Remainder Theorem Grade 9 Grade 10 ★★★★☆

Call a number automorphic if its square ends with the decimal notation of the number itself. Prove that there are infinitely many automorphic numbers different from \(0\) and \(1\).

Details
Problem: NT-B2-M11-P015
Difficulty: Level 4 of 5
Tag: Chinese Remainder Theorem
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 243
#11.16
#11.16

The Period Equals the Product

Digits Grade 9 Grade 10 ★★★★☆

Find all reduced proper fractions \(\frac{a}{b}\) whose decimal expansion is an infinite repetition of the decimal notation of the number \(ab\). For example, \(\frac13=0.\overline3\).

Details
Problem: NT-B2-M11-P016
Difficulty: Level 4 of 5
Tag: Digits
Grade: Grade 9, Grade 10
Source: 1001 Problems in Classical Number Theory (method inspiration) · Problem 347
#11.17
#11.17

Blocks and a Lower Bound for Digit Sum

Digits Grade 10 Grade 11 ★★★★★

Let \(k\ge1\). Split the decimal representation of a positive integer \(M\) from right to left into blocks of \(k\) digits, and let \(T(M)\) be the sum of these blocks as ordinary integers. Prove that \(M\equiv T(M)\pmod{10^k-1}\). Then prove: if \(10^k-1\mid M\), then the digit sum of \(M\) is at least \(9k\).

Details
Problem: NT-B2-M11-P017
Difficulty: Level 5 of 5
Tag: Digits
Grade: Grade 10, Grade 11
Source: Inspired by regional olympiad method · 2022 · Grade 9 · Problem 10
#11.18
#11.18

The Digit Sum of a Factorial

Digits Grade 10 Grade 11 ★★★★★

Prove that for every positive integer \(A\) there exists a positive integer \(B\) such that for all \(n\ge B\), the sum of the decimal digits of \(n!\) is at least \(A\).

Details
Problem: NT-B2-M11-P018
Difficulty: Level 5 of 5
Tag: Digits
Grade: Grade 10, Grade 11
Source: Inspired by regional olympiad method · 2022 · Grade 9 · Problem 10
#11.19
#11.19

Period Exactly Three

Divisibility Grade 9 Grade 10 ★★★★☆

Find all \(n>1\), coprime to \(10\), for which the decimal expansion of \(\frac1n\) has period exactly \(3\).

Details
Problem: NT-B2-M11-P019
Difficulty: Level 4 of 5
Tag: Divisibility
Grade: Grade 9, Grade 10
#11.20
#11.20

Prime Divisors of a Prime-Length Repunit

Prime Factorisation Grade 10 Grade 11 ★★★★★

Let \(q\) be an odd prime and \(R_q=\frac{10^q-1}{9}\). Prove that every prime divisor \(p\ne3\) of \(R_q\) satisfies \(p\equiv1\pmod q\).

Details
Problem: NT-B2-M11-P020
Difficulty: Level 5 of 5
Tag: Prime Factorisation
Grade: Grade 10, Grade 11

Ladders

No published ladders were found.
Previous Chapter
Next Chapter