Module 3.2 · Number Theory
Primes and prime factorization
Every whole number greater than is built from primes in exactly one way, the way a molecule is built from atoms. Once you write a number as a product of primes, many contest questions become bookkeeping: perfect squares, factors of factorials, and "what must divide this?"
Primes and how to test them
Definition
Prime number
A prime is a whole number greater than whose only positive divisors are and itself. A whole number greater than that is not prime is composite. The number is neither.
The primes below are worth memorizing: .
Notice that is the only even prime. This one fact solves a surprising number of problems: if two primes add to an odd number, one of them must be .
Testing a number for primality. If is composite, it can be written as with . Then , so . That means you only need to check primes up to .
Worked example: Is 221 prime?
is a bit less than (since ), so test the primes .
is odd, its digit sum is , and it doesn't end in or . Try : , remainder . Try : alternating sum , no. Try : . So is composite.
Common mistake
Numbers like , , , and "look prime" and trap students every year. Always finish the check up to .
Prime factorization
Fundamental Theorem of Arithmetic
Every whole number greater than can be written as a product of primes in exactly one way (ignoring order). For example, .
To find it, divide out small primes one at a time: , dividing by .
Perfect powers. A number is a perfect square exactly when every exponent in its factorization is even, and a perfect cube when every exponent is a multiple of .
Worked example: Make a perfect square
What is the smallest positive integer such that is a perfect square?
. The exponent of is odd and the exponent of is odd. Multiply by one more and one more : . Then .
Worked example: What must divide it?
A six-digit number has the form , like . Which prime greater than must divide every such number?
, and . So every such number is divisible by and . The prime greater than is 37.
Primes inside factorials
How many times does the prime divide ? Count the multiples of up to , then add the multiples of (each contributes an extra factor), then , and so on:
Here means "round down to a whole number."
Worked example: Trailing zeros
How many zeros are at the end of ?
Each trailing zero is a factor of . There are far more s than s, so count the s: .
So ends in 24 zeros. The numbers each contribute two s, which the second term counts.
Practice
What is the sum of all prime numbers between and ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the sum of the distinct prime factors of ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Which of the following is prime?
Two prime numbers differ by . What is their sum?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the smallest positive integer such that is a perfect square?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the smallest positive integer such that is a perfect cube?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
How many zeros are at the end of ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
What is the largest integer such that divides ?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 2017 AMC 8, Problem 19: counting factors of in a sum of factorials.
- 2018 AMC 8, Problem 18: prime factorization of a five-digit number (also good practice for counting divisors).