Skip to content
Number Theory · Chapter 21

Primes and Factors

Break numbers into primes, then count, add and multiply their divisors straight from the exponents.

You'll need
open on YouTube
21.00%

Primes, Factorization and Counting Divisors

In this section you will be able to write any number as a product of primes and count its divisors straight from the exponents.

Twin brothers and their sister have ages that multiply to 128128. Only one prime hides in 128128, so every age is a power of 22.

Every whole number above 11 splits into primes in exactly one way. In the factor tree under Concept 21.0.3, split 6060 as 6×106 \times 10, then start over with 4×154 \times 15. The leaves come out the same: 2,2,3,52, 2, 3, 5.

That one factorization tells you everything about the divisors. A divisor of 60=22⋅3⋅560 = 2^2 \cdot 3 \cdot 5 just picks an exponent for each prime: 00 to 22 for the 22, 00 or 11 for the 33 and the 55. Look: each divisor is one point of the lattice above.

A perfect square has only even exponents. So counting square divisors means counting even exponents, one prime at a time.

Exploreplay first, formulas later

60 = 2² × 3 × 5: 3 × 2 × 2 = 12 factors

Light up:
exponent of 22
exponent of 31
exponent of 51

n = 60 = 2² × 3 × 5

× 5⁰
2⁰2¹2²3⁰3¹1243612
× 5¹
2⁰2¹2²3⁰3¹51020153060
  • Powers of 2:2⁰, 2¹, 2² → 3 choices
  • Powers of 3:3⁰, 3¹ → 2 choices
  • Powers of 5:5⁰, 5¹ → 2 choices
3 × 2 × 2 = 12 factors

60 = 2² × 3 × 5: 3 × 2 × 2 = 12 factors

Name it

Definition 21.0.1 · Primes

Primes are numbers that have exactly two factors: 11 and the number itself. For example, 2,3,5,7,11,13,17,19,23,…2, 3, 5, 7, 11, 13, 17, 19, 23, \ldots are all primes.

Remark 21.0.2

To check whether a number nn is prime, you only need to test the primes that are less than or equal to n\sqrt{n}.

Prime factorization of 97: 97

97 = 97all prime!

97 is prime: none of 2, 3, 5, 7 divides it, and the next prime, 11, is bigger than √97 ≈ 9.85. No split exists.

97 = 97. Every leaf is prime.

Concept 21.0.3 · Prime Factorization

Prime factorization writes a number as a product of primes.

Example: the prime factorization of 6060 is 22×3×52^2 \times 3 \times 5.

Prime factorization of 60: 2^2 × 3 × 5

Split 60 as:

60 = 60keep splitting

60 = 60. Some leaves can still be split.

Theorem 21.0.4 · Number of Factors of a Number

If the prime factorization of a number is

p1e1×p2e2×⋯×pkek,p_1^{e_1} \times p_2^{e_2} \times \cdots \times p_k^{e_k},

then the number of factors of this number is

(e1+1)(e2+1)⋯(ek+1).(e_1 + 1)(e_2 + 1)\cdots(e_k + 1).

Watch itpredict, then reveal

Example 21.1

AMC 10

Kiana has two older twin brothers. The product of their three ages is 128128. What is the sum of their three ages?

Factor tree (its total is revealed at the end of the example)

Split 128 as:

128 = 128keep splitting

128 = 128. Some leaves can still be split.

  1. 1

    Factor 128128 into primes. It is a power of 22: 128=2k128 = 2^k. What is kk?

    Predict first:
open on YouTube

Example 21.2

AIME

Let n=231319n = 2^{31} 3^{19}. How many positive integer divisors of n2n^2 are less than nn but do not divide nn?

Exponent lattice (its total is revealed at the end of the example)

Light up:
exponent of 2 in n3
exponent of 3 in n2

n² = 2⁶ × 3⁴, n = 2³ × 3²

2⁰2¹2²2³2⁴2⁵2⁶3⁰3¹3²3³3⁴12481632643612244896192918367214428857627541082164328641,728811623246481,2962,5925,184
  • The line is d = n. Lit points sit below it (d < n) but outside the dashed box of the divisors of n.
(7 × 5 − 1)/2 − (4 × 3 − 1) = ? (hidden until the end of the example)

5,184 = 2⁶ × 3⁴: total hidden

  1. 1

    Start small: n=23⋅32=72n = 2^3 \cdot 3^2 = 72, so n2=26⋅34n^2 = 2^6 \cdot 3^4. How many divisors does n2n^2 have?

    Predict first:
open on YouTube

Example 21.3

AIME

Let nn be the smallest positive integer that is a multiple of 7575 and has exactly 7575 positive integral divisors, including 11 and itself. Find n75\frac{n}{75}.

Factor tree (its total is revealed at the end of the example)

Split 75 as:

75 = 75keep splitting

75 = 75. Some leaves can still be split.

  1. 1

    75=3⋅5275 = 3 \cdot 5^2. Which primes must nn contain, and at least how often?

    Predict first:
    Click a choice or type its letter (A–E).
open on YouTube

Try it

Problem 21.3.6

AMC 10

How many positive even multiples of 33 less than 20202020 are perfect squares?

Problem 21.3.7

AMC 10

How many positive integer divisors of 2019201^9 are perfect squares or perfect cubes (or both)?

535,506,216,522,273,441,801 = 3⁹ × 67⁹: 5 × 5 = 25 perfect-square factors

Light up:
exponent of 39
exponent of 679

n = 535,506,216,522,273,441,801 = 3⁹ × 67⁹

3⁰3¹3²⋯3⁷3⁸3⁹67⁰67¹67²⋮67⁷67⁸67⁹1392,1876,56119,68367201603146,529439,5873⁹·674,48913,46740,4013⁷·67²3⁸·67²3⁹·67²67⁷3·67⁷3²·67⁷3⁷·67⁷3⁸·67⁷3⁹·67⁷67⁸3·67⁸3²·67⁸3⁷·67⁸3⁸·67⁸3⁹·67⁸67⁹3·67⁹3²·67⁹3⁷·67⁹3⁸·67⁹3⁹·67⁹
  • Powers of 3:3⁰, 3², 3⁴, 3⁶, 3⁸ → 5 choices
  • Powers of 67:67⁰, 67², 67⁴, 67⁶, 67⁸ → 5 choices
5 × 5 = 25 perfect-square factors

535,506,216,522,273,441,801 = 3⁹ × 67⁹: 5 × 5 = 25 perfect-square factors

Problem 21.3.16

AMC 10

How many positive two-digit integers are factors of 224−12^{24} - 1?

Contest cornerreal contest problems

Problem 21.3.1

AMC 10

A positive integer divisor of 12!12! is chosen at random. The probability that the divisor chosen is a perfect square can be expressed as mn\frac{m}{n}, where mm and nn are relatively prime positive integers. What is m+nm + n?

Problem 21.3.11

AMC 10

For some positive integer nn, the number 110n3110n^3 has 110110 positive integer divisors, including 11 and the number 110n3110n^3. How many positive integer divisors does the number 81n481n^4 have?

Problem 21.3.22

AIME

Find the number of ordered pairs of positive integers (m,n)(m, n) such that m2n=2020m^2 n = 20^{20}.

Problem 21.3.34(additional)

AIME

How many positive integer divisors of 200420042004^{2004} are divisible by exactly 20042004 positive integers?

Checkpoint for section 21.0

Get 2 of 3 right to master this section. One try each, no hints.
1

How many positive divisors does 360360 have?

2

How many positive divisors of 24⋅332^4 \cdot 3^3 are perfect squares?

3

What is the smallest prime factor of 221221? (You only need to test primes up to 221<15\sqrt{221} < 15.)

21.10%

Sum of Factors

In this section you will be able to add up all the divisors of a number by multiplying one geometric sum per prime.

The divisors of 1212 are 1,2,3,4,6,121, 2, 3, 4, 6, 12, and they add up to 2828. So does (1+2+4)(1+3)(1 + 2 + 4)(1 + 3). That is no accident.

Expand (1+2+4)(1+3)(1 + 2 + 4)(1 + 3): every term picks one power of 22 and one power of 33. That is exactly one divisor of 1212 each time. So one sum per prime, multiplied together, adds up every divisor.

Each bracket is a geometric series: 1+p+⋯+pe=pe+1−1p−11 + p + \cdots + p^{e} = \frac{p^{e+1} - 1}{p - 1}.

Need only the odd divisors? Drop the bracket for 22. The book prints Example 21.4 in Section 21.2, but it is a divisor-sum problem, so you’ll meet it here.

Exploreplay first, formulas later

12 = 2² × 3: sum of factors = 7 × 4 = 28

Light up:
exponent of 22
exponent of 31

n = 12 = 2² × 3

2⁰2¹2²3⁰3¹1243612
  • Powers of 2:1 + 2 + 4 = 7
  • Powers of 3:1 + 3 = 4
7 × 4 = 28
(1+p1+⋯+p1e1)⋯(1+pk+⋯+pkek)7×4=28(1+p_1+\cdots+p_1^{e_1})\cdots(1+p_k+\cdots+p_k^{e_k}) \quad 7\times4 = 28

n=22×31n = 2^{2} \times 3^{1}

12 = 2² × 3: sum of factors = 7 × 4 = 28

Name it

Theorem 21.1.1 · Sum of Factors of a Number

If the prime factorization of a number is

p1e1×p2e2×⋯×pkek,p_1^{e_1} \times p_2^{e_2} \times \cdots \times p_k^{e_k},

then the sum of the factors of this number is

(1+p1+p12+⋯+p1e1)(1+p2+p22+⋯+p2e2)⋯(1+pk+pk2+⋯+pkek).(1 + p_1 + p_1^2 + \cdots + p_1^{e_1})(1 + p_2 + p_2^2 + \cdots + p_2^{e_2})\cdots(1 + p_k + p_k^2 + \cdots + p_k^{e_k}).

Concept 21.1.2 · Sum of Factors of a Number

For each prime pp in the prime factorization, first find the sum of pkp^k over all the possible exponents kk (from 00 up to the exponent of pp). Then multiply these sums over all of the primes to get the sum of all the factors of the number.

Watch itpredict, then reveal

Example 21.4

AMC 12

For nn a positive integer, let f(n)f(n) be the quotient obtained when the sum of all positive divisors of nn is divided by nn. For example,

f(14)=(1+2+7+14)÷14=127.f(14) = (1 + 2 + 7 + 14) \div 14 = \frac{12}{7}.

What is f(768)−f(384)f(768) - f(384)?

Exponent lattice (its total is revealed at the end of the example)

exponent of 28
exponent of 31

n = 768 = 2⁸ × 3

2⁰2¹2²2³2⁴2⁵2⁶2⁷2⁸3⁰3¹12481632641282563612244896192384768
  • Powers of 2:1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 = 511
  • Powers of 3:1 + 3 = 4
511 × 4 = ? (hidden until the end of the example)

768 = 2⁸ × 3: total hidden

  1. 1

    Factor both numbers. 768=2a⋅3768 = 2^a \cdot 3 and 384=2a−1⋅3384 = 2^{a-1} \cdot 3. What is aa?

    Predict first:
open on YouTube

Try it

Problem 21.3.23

AMC 10/12

Let N=34⋅34⋅63⋅270N = 34 \cdot 34 \cdot 63 \cdot 270. What is the ratio of the sum of the odd divisors of NN to the sum of the even divisors of NN?

72 = 2³ × 3²: sum of odd factors = 1 × 13 = 13

Light up:
exponent of 23
exponent of 32

n = 72 = 2³ × 3²

2⁰2¹2²2³3⁰3¹3²12483612249183672
  • Powers of 2:1 = 1
  • Powers of 3:1 + 3 + 9 = 13
1 × 13 = 13

72 = 2³ × 3²: sum of odd factors = 1 × 13 = 13

Contest cornerreal contest problems

Problem 21.3.36(additional)

AIME

Let SS be the sum of all numbers of the form a/ba/b, where aa and bb are relatively prime positive divisors of 10001000. What is the greatest integer that does not exceed S/10S/10?

Checkpoint for section 21.1

Get 2 of 3 right to master this section. One try each, no hints.
1

What is the sum of the positive divisors of 1212?

2

What is the sum of the positive divisors of 100100?

3

What is the sum of the odd positive divisors of 7272?

21.20%

Product of Factors

In this section you will be able to multiply all the divisors of a number at once by pairing each divisor d with n/d.

The divisors of 3636 pair up: 1×361 \times 36, 2×182 \times 18, 3×123 \times 12, 4×94 \times 9. Each pair multiplies to 3636. And 66 is left over, paired with itself.

Pair every divisor dd with its partner nd\frac{n}{d}. On the lattice, partners sit opposite each other across the center. With ff divisors there are f2\frac{f}{2} pairs, each worth nn, so the product is nf/2n^{f/2}.

When nn is a perfect square, the middle divisor n\sqrt{n} is its own partner. It counts as half a pair, and the formula still works.

Exploreplay first, formulas later

36 = 2² × 3²: product of 9 factors = 36^(9/2) = 10,077,696

Light up:
exponent of 22
exponent of 32

n = 36 = 2² × 3²

2⁰2¹2²3⁰3¹3²124361291836

You picked 2⁰ × 3¹ = 3. Its partner is 2² × 3¹ = 12, and 3 × 12 = 36.

  • Powers of 2:2⁰, 2¹, 2² → 3 choices
  • Powers of 3:3⁰, 3¹, 3² → 3 choices
  • Mirror points pair up across the center. Each pair multiplies to 36. There are 9 factors, so 9/2 pairs (the middle one pairs with itself, so it counts as half a pair).
36^(9/2) = 10,077,696

36 = 2² × 3²: product of 9 factors = 36^(9/2) = 10,077,696

Name it

Theorem 21.2.1 · Product of Factors of a Number

If a number nn has ff factors (count them with the number-of-factors formula), then the product of the factors of nn is

nf/2.n^{f/2}.

Contest cornerreal contest problems

Problem 21.3.12

AMC 10

Let SS be the set of all positive integer divisors of 100,000100{,}000. How many numbers are the product of two distinct elements of SS?

Problem 21.3.33(additional)

AMC 10

Given that 38⋅52=ab3^8 \cdot 5^2 = a^b, where both aa and bb are positive integers, find the smallest possible value for a+ba + b.

Checkpoint for section 21.2

Get 2 of 3 right to master this section. One try each, no hints.
1

What is the product of all the positive divisors of 1212?

2

The product of all the positive divisors of nn is n5n^5. How many divisors does nn have? (Assume n>1n > 1.)

3

The product of all the positive divisors of 1616 is 2k2^k. What is kk?

21.3

Practice Problems

In this section you will be able to mix primes, divisor counts and divisibility on contest problems from across the chapter.

Not every problem here says “divisor” out loud. Factor first anyway: primes, parity and last digits crack most of them.

Problems 21.3.24 to 21.3.38 are the book’s Additional Problems. The last two are challenge problems. Every problem has three hints if you get stuck.

Want every problem from this chapter on one page? Open the problem set.

Contest cornerreal contest problems

Problem 21.3.2

AMC 10

A single bench section at a school event can hold either 77 adults or 1111 children. When NN bench sections are connected end to end, an equal number of adults and children seated together will occupy all the bench space. What is the least possible positive integer value of NN?

Click a choice or type its letter (A–E).

Problem 21.3.3

AMC 10

What is the least positive integer mm such that m⋅2!⋅3!⋅4!⋅5!⋯16!m \cdot 2! \cdot 3! \cdot 4! \cdot 5! \cdots 16! is a perfect square?

Problem 21.3.4

AMC 10

For how many (not necessarily positive) integer values of nn is the value of 4000⋅(25)n4000 \cdot \left(\frac{2}{5}\right)^n an integer?

Problem 21.3.5

AMC 10

The numbers from 11 to 88 are placed at the vertices of a cube in such a manner that the sum of the four numbers on each face is the same. What is this common sum?

Problem 21.3.8

AMC 12

What is the sum of the exponents of the prime factors of the square root of the largest perfect square that divides 12!12!?

Problem 21.3.9

AMC 10

How many ways are there to write 20162016 as the sum of twos and threes, ignoring order? (For example, 1008⋅2+0⋅31008 \cdot 2 + 0 \cdot 3 and 402⋅2+404⋅3402 \cdot 2 + 404 \cdot 3 are two such ways.)

Problem 21.3.10

AIME

Find the number of positive integers with three not necessarily distinct digits, abcabc, with a≠0a \neq 0 and c≠0c \neq 0 such that both abcabc and cbacba are multiples of 44.

Problem 21.3.13

AMC 10

The 2525 integers from −10-10 to 1414, inclusive, can be arranged to form a 55-by-55 square in which the sum of the numbers in each row, the sum of the numbers in each column, and the sum of the numbers along each of the main diagonals are all the same. What is the value of this common sum?

Problem 21.3.14

AMC 10

All the numbers 2,3,4,5,6,72, 3, 4, 5, 6, 7 are assigned to the six faces of a cube, one number to each face. For each of the eight vertices of the cube, a product of three numbers is computed, where the three numbers are the numbers assigned to the three faces that include that vertex. What is the greatest possible value of the sum of these eight products?

Problem 21.3.15

AMC 12

How many odd positive 33-digit integers are divisible by 33 but do not contain the digit 33?

Problem 21.3.17

AIME

There is a prime number pp such that 16p+116p + 1 is the cube of a positive integer. Find pp.

Problem 21.3.18

AMC 10

Joey and Chloe and their daughter Zoe all have the same birthday. Joey is 11 year older than Chloe, and Zoe is exactly 11 year old today. Today is the first of the 99 birthdays on which Chloe's age will be an integral multiple of Zoe's age. What will be the sum of the two digits of Joey's age the next time his age is a multiple of Zoe's age?

Problem 21.3.19

AMC 10

What is the tens digit of 20152016−20172015^{2016} - 2017?

Problem 21.3.20

AMC 10

Let N=123456789101112…4344N = 123456789101112\dots4344 be the 7979-digit number that is formed by writing the integers from 11 to 4444 in order, one after the other. What is the remainder when NN is divided by 4545?

Problem 21.3.21

AMC 10

What is the hundreds digit of (20!−15!)(20! - 15!)?

Problem 21.3.24(additional)

AMC 12

In multiplying two positive integers aa and bb, Ron reversed the digits of the two-digit number aa. His erroneous product was 161161. What is the correct value of the product of aa and bb?

Problem 21.3.25(additional)

AMC 10

Positive integers aa, bb, and 20092009, with a<b<2009a < b < 2009, form a geometric sequence with an integer ratio. What is aa?

Problem 21.3.26(additional)

AMC 10

How many positive cubes divide 3!⋅5!⋅7!3! \cdot 5! \cdot 7!?

Problem 21.3.27(additional)

AMC 12

This problem also appears in the book as 21.3.23.

Let N=34⋅34⋅63⋅270N = 34 \cdot 34 \cdot 63 \cdot 270. What is the ratio of the sum of the odd divisors of NN to the sum of the even divisors of NN?

Problem 21.3.28(additional)

AMC 10

Suppose that mm and nn are positive integers such that 75m=n375m = n^3. What is the minimum possible value of m+nm + n?

Prime factorization of 75: 3 × 5^2

Split 75 as:

75 = 75keep splitting

75 = 75. Some leaves can still be split.

Problem 21.3.29(additional)

AMC 10

Elmo makes NN sandwiches for a fundraiser. For each sandwich he uses BB globs of peanut butter at 44¢ per glob and JJ blobs of jam at 55¢ per blob. The cost of the peanut butter and jam to make all the sandwiches is $2.53. Assume that BB, JJ, and NN are positive integers with N>1N > 1. What is the cost of the jam Elmo uses to make the sandwiches?

Problem 21.3.30(additional)

AMC 12

The largest prime factor of 1638416384 is 22 because 16384=21416384 = 2^{14}. What is the sum of the digits of the greatest prime number that is a divisor of 1638316383?

Problem 21.3.31(additional)

AMC 12

How many ways are there to paint each of the integers 2,3,…,92, 3, \ldots, 9 either red, green, or blue so that each number has a different color from each of its proper divisors?

Problem 21.3.32(additional)

AMC 10

The positive integers AA, BB, A−BA - B, and A+BA + B are all prime numbers. The sum of these four primes is

Click a choice or type its letter (A–E).

Problem 21.3.35(additional)

AIME

Find the number of positive integers that are divisors of at least one of 101010^{10}, 15715^7, 181118^{11}.

Problem 21.3.37(additional)

AMC 12Challenge

For each positive integer nn, let f1(n)f_1(n) be twice the number of positive integer divisors of nn, and for j≥2j \ge 2, let fj(n)=f1(fj−1(n))f_j(n) = f_1(f_{j-1}(n)). For how many values of n≤50n \le 50 is f50(n)=12f_{50}(n) = 12?

Problem 21.3.38(additional)

AMC 10Challenge

For each positive integer n>1n > 1, let P(n)P(n) denote the greatest prime factor of nn. For how many positive integers nn is it true that both P(n)=nP(n) = \sqrt{n} and P(n+48)=n+48P(n + 48) = \sqrt{n + 48}?