← Back to Competition Math

Number Theory Basics

Competition Math · AMC 8 LevelPreview

1. Introduction

Number theory is the study of the integers, and on the AMC 8 it shows up constantly: counting divisors, finding the greatest common divisor of two numbers, deciding whether a big number is divisible by 99, or hunting for the smallest integer with a special property. Almost every one of these problems becomes easy once you can do one thing well — break a number into its prime factorization.

The reason primes matter so much is that they are the atoms of multiplication. Every whole number bigger than 11 is either prime itself or can be built by multiplying primes together, and there is essentially only one way to do it. Once you see a number like 360360 as 233252^3 \cdot 3^2 \cdot 5, questions like "how many divisors does it have?" or "what is its GCD with 8484?" turn into quick exponent bookkeeping instead of guesswork.

In this article you will learn the divisibility rules and why they work, the Fundamental Theorem of Arithmetic, how to count divisors and sum them, how to compute the GCD and LCM both by factoring and by the lightning-fast Euclidean algorithm, modular thinking for digit puzzles, and how all of these combine in real contest problems. Master this material and a large slice of the AMC 8 number-theory questions become routine.

2. Core Concepts

Concept 1 — Divisibility and Factors

We say an integer dd divides nn, written dnd \mid n, if n=dqn = dq for some integer qq — that is, nn divided by dd leaves no remainder. Then dd is a divisor (or factor) of nn, and nn is a multiple of dd. For example 7567 \mid 56 because 56=7856 = 7 \cdot 8, but 7507 \nmid 50.

Every positive integer nn has at least two divisors, 11 and nn itself. A prime is an integer greater than 11 whose only divisors are 11 and itself: 2,3,5,7,11,13,2, 3, 5, 7, 11, 13, \dots. A composite is an integer greater than 11 that is not prime. The number 11 is special: it is neither prime nor composite.

Concept 2 — The Fundamental Theorem of Arithmetic

Fundamental Theorem of Arithmetic. Every integer n>1n > 1 can be written as a product of primes, and this factorization is unique up to the order of the factors. We collect repeated primes into powers: n=p1e1p2e2pkek,n = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k}, where the pip_i are distinct primes and each exponent ei1e_i \geq 1. For instance 360=23325360 = 2^3 \cdot 3^2 \cdot 5 and 1000=23531000 = 2^3 \cdot 5^3.

This uniqueness is the engine behind nearly every technique below. To factor a number by hand, repeatedly divide out the smallest prime that fits: 36018090451551360 \to 180 \to 90 \to 45 \to 15 \to 5 \to 1, recording 2,2,2,3,3,52, 2, 2, 3, 3, 5.

Concept 3 — Why Divisibility Rules Work

Divisibility rules come from the place-value structure of base ten. Since 101(mod3)10 \equiv 1 \pmod 3 and 101(mod9)10 \equiv 1 \pmod 9, every power of 1010 leaves remainder 11, so a number is congruent to its digit sum modulo 33 and modulo 99. Since 101(mod11)10 \equiv -1 \pmod{11}, powers of 1010 alternate +1,1,+1,+1, -1, +1, \dots, which is why the alternating digit sum controls divisibility by 1111. And because 100100 is a multiple of 44 (and 10001000 a multiple of 88), only the last two digits matter for 44 and the last three for 88.

Concept 4 — Divisibility by 2, 5, and 10

A number is divisible by 22 when its last digit is even (0,2,4,6,80, 2, 4, 6, 8). It is divisible by 55 when its last digit is 00 or 55. It is divisible by 1010 when its last digit is 00. These follow because 10=2510 = 2 \cdot 5 and 1010k10 \mid 10^k for every k1k \geq 1, so only the units digit of nn matters for divisibility by 22 or 55.

Concept 5 — Divisibility by 3 and 9

Theorem (digit-sum test). An integer nn is divisible by 33 (resp. 99) if and only if the sum of its decimal digits is divisible by 33 (resp. 99).

Example: 1,234,5671{,}234{,}567 has digit sum 1+2+3+4+5+6+7=281+2+3+4+5+6+7 = 28. Since 28≢0(mod3)28 \not\equiv 0 \pmod 3, the number is not divisible by 33. For 99, note 281(mod9)28 \equiv 1 \pmod 9, so it is not divisible by 99 either.

Concept 6 — Divisibility by 4, 8, and 11

  • By 44: check whether the number formed by the last two digits is a multiple of 44. Example: 123,456123{,}456 ends in 5656, and 56=41456 = 4 \cdot 14, so 4123,4564 \mid 123{,}456.
  • By 88: check the last three digits. Example: 7,0247{,}024 ends in 024=83024 = 8 \cdot 3, so 87,0248 \mid 7{,}024.
  • By 1111: form the alternating sum of digits from the right: d0d1+d2d3+d_0 - d_1 + d_2 - d_3 + \cdots. The number is divisible by 1111 iff this alternating sum is divisible by 1111. Example: 91,81991{,}819 gives 91+81+9=249 - 1 + 8 - 1 + 9 = 24, not divisible by 1111.

Concept 7 — GCD and LCM

The greatest common divisor gcd(a,b)\gcd(a,b) is the largest integer dividing both aa and bb. The least common multiple lcm(a,b)\operatorname{lcm}(a,b) is the smallest positive integer that both aa and bb divide. Two integers with gcd(a,b)=1\gcd(a,b)=1 are called relatively prime or coprime.

In terms of prime factorizations, the GCD takes the minimum exponent of each shared prime and the LCM takes the maximum exponent of every prime that appears in either number.

Concept 8 — The GCD–LCM Identity

Theorem. For any positive integers aa and bb, gcd(a,b)lcm(a,b)=ab.\gcd(a,b) \cdot \operatorname{lcm}(a,b) = a \cdot b. Knowing any three of these four quantities gives the fourth instantly. This identity is one of the fastest sanity checks on contest problems.

Concept 9 — The Euclidean Algorithm

When numbers are large or awkward to factor, use the Euclidean algorithm: gcd(a,b)=gcd(b,amodb)\gcd(a,b) = \gcd(b, a \bmod b), repeating until the remainder is 00. The last nonzero remainder is the GCD. This algorithm is guaranteed to terminate and is far faster than factoring for large integers.

Concept 10 — Counting Divisors

If n=p1e1pkekn = p_1^{e_1} \cdots p_k^{e_k}, each divisor is built by choosing an exponent from 00 to eie_i for each prime pip_i. Hence the divisor-count formula: d(n)=(e1+1)(e2+1)(ek+1).d(n) = (e_1+1)(e_2+1)\cdots(e_k+1). A perfect square is exactly the positive integer whose divisor count is odd, because one exponent can be chosen in only one way to pair with itself (the middle exponent when all exponents are even).

Concept 11 — Sum of Divisors

The sum-of-divisors function σ(n)\sigma(n) adds every positive divisor of nn. From the prime factorization, σ(n)=i=1k(1+pi+pi2++piei)=i=1kpiei+11pi1.\sigma(n) = \prod_{i=1}^{k} \left(1 + p_i + p_i^2 + \cdots + p_i^{e_i}\right) = \prod_{i=1}^{k}\frac{p_i^{e_i+1}-1}{p_i-1}. This appears when a problem asks for "the sum of all factors" or "the sum of proper divisors."

Concept 12 — Trailing Zeros and Prime Powers in Factorials

The number of trailing zeros in n!n! equals the number of factors of 55 in n!n!, because factors of 22 are always more plentiful: ν5(n!)=n5+n25+n125+.\nu_5(n!) = \left\lfloor \frac{n}{5} \right\rfloor + \left\lfloor \frac{n}{25} \right\rfloor + \left\lfloor \frac{n}{125} \right\rfloor + \cdots. More generally, the exponent of a prime pp in n!n! is n/p+n/p2+\lfloor n/p \rfloor + \lfloor n/p^2 \rfloor + \cdots.

Continue reading with Premium

Upgrade to read the full article and unlock all Premium features.

Free

  • Unlimited practice — all difficulties
  • 3 hints / day
  • Community solutions
  • 2 timed mocks / month

Premium

  • Full article + all 57+ theory guides
  • Unlimited hints on practice problems
  • Unlimited timed mock exams & PDF worksheets
Log in