Math Core

Module 3.1 · Number Theory

Divisors and prime factorization

On the AMC 10 and 12, "how many divisors" is only the warm-up. The real questions ask for the sum of the divisors, their product, divisors with a special property, or pairs of numbers with a given GCD and LCM. Every one of these is answered the same way: write the number as a product of prime powers and think about each prime separately.

Divisors are exponent choices

If n=p1a1p2a2⋯pkakn = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}, then every divisor of nn looks like p1e1p2e2⋯pkekp_1^{e_1} p_2^{e_2} \cdots p_k^{e_k} with 0≤ei≤ai0 \le e_i \le a_i, and different exponent choices give different divisors. So a divisor is nothing more than a list of independent choices, one per prime. That single fact gives you all of the formulas below.

  • Counting. Prime pip_i has ai+1a_i + 1 exponent choices, so d(n)=(a1+1)(a2+1)⋯(ak+1)d(n) = (a_1 + 1)(a_2 + 1)\cdots(a_k + 1).
  • Restricted counting. To count divisors with a property (perfect square, multiple of 1212, odd), restrict the exponent choices for each prime and multiply. A square divisor needs every exponent even; an odd divisor needs the exponent of 22 to be 00.

The sum of the divisors

Expand the product

(1+2+22+23)(1+3+32).(1 + 2 + 2^2 + 2^3)(1 + 3 + 3^2).

Each term of the expansion picks one power of 22 and one power of 33 and multiplies them, so the expansion lists every divisor of 23⋅32=722^3 \cdot 3^2 = 72 exactly once. The sum of the divisors of 7272 is 15⋅13=19515 \cdot 13 = 195.

Divisor formulas

For n=p1a1p2a2⋯pkakn = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}:

  • Number of divisors: d(n)=(a1+1)(a2+1)⋯(ak+1)d(n) = (a_1 + 1)(a_2 + 1) \cdots (a_k + 1).
  • Sum of divisors: σ(n)=(1+p1+⋯+p1a1)⋯(1+pk+⋯+pkak)\sigma(n) = (1 + p_1 + \dots + p_1^{a_1}) \cdots (1 + p_k + \dots + p_k^{a_k}), and each factor equals piai+1−1pi−1\dfrac{p_i^{a_i + 1} - 1}{p_i - 1}.
  • Product of divisors: nd(n)/2n^{d(n)/2}.

The product of the divisors

Divisors come in pairs dd and nd\dfrac{n}{d} whose product is nn. There are d(n)d(n) divisors, so there are d(n)2\dfrac{d(n)}{2} pairs and the product of all the divisors is nd(n)/2n^{d(n)/2}. This works even when nn is a perfect square: the middle divisor n\sqrt{n} pairs with itself and contributes n1/2n^{1/2}, which is exactly what the formula gives.

GCD and LCM, one prime at a time

For each prime, gcd⁡(a,b)\gcd(a, b) uses the smaller exponent and lcm⁡(a,b)\operatorname{lcm}(a, b) uses the larger one. So if you know the LCM (or both the GCD and LCM), you can count pairs (a,b)(a, b) prime by prime:

  • If lcm⁡(a,b)\operatorname{lcm}(a, b) has pkp^k, the exponents of pp in aa and bb are at most kk and at least one equals kk: that's (k+1)2−k2=2k+1(k+1)^2 - k^2 = 2k + 1 ordered choices.
  • If gcd⁡(a,b)\gcd(a, b) has pjp^j and lcm⁡(a,b)\operatorname{lcm}(a, b) has pkp^k with j<kj < k, one number gets jj and the other gets kk: 22 ordered choices. If j=kj = k there is only 11.

Worked example: A sum of divisors

What is the sum of the positive divisors of 720720?

720=24⋅32⋅5720 = 2^4 \cdot 3^2 \cdot 5, so

σ(720)=(1+2+4+8+16)(1+3+9)(1+5)=31⋅13⋅6=2418.\sigma(720) = (1 + 2 + 4 + 8 + 16)(1 + 3 + 9)(1 + 5) = 31 \cdot 13 \cdot 6 = 2418.

Worked example: Pairs with a given LCM

How many ordered pairs of positive integers (a,b)(a, b) have lcm⁡(a,b)=72\operatorname{lcm}(a, b) = 72?

72=23⋅3272 = 2^3 \cdot 3^2. For the prime 22, the exponents in aa and bb lie in {0,1,2,3}\{0, 1, 2, 3\} with at least one equal to 33: 42−32=74^2 - 3^2 = 7 choices. For the prime 33: 32−22=53^2 - 2^2 = 5 choices. The primes are independent, so there are 7⋅5=357 \cdot 5 = 35 ordered pairs.

Worked example: Divisors of the square

Let n=432=24⋅33n = 432 = 2^4 \cdot 3^3. How many positive divisors of n2n^2 are less than nn but do not divide nn?

n2=28⋅36n^2 = 2^8 \cdot 3^6 has 9⋅7=639 \cdot 7 = 63 divisors. Apart from nn itself, they pair up as dd and n2d\dfrac{n^2}{d} with exactly one of each pair below nn, so 63−12=31\dfrac{63 - 1}{2} = 31 divisors of n2n^2 are less than nn.

Every divisor of nn also divides n2n^2. The number nn has 5⋅4=205 \cdot 4 = 20 divisors, and 1919 of them are less than nn. So the answer is 31−19=1231 - 19 = 12.

Worked example: Working backward from the product

The product of all the positive divisors of a positive integer nn is 230⋅3152^{30} \cdot 3^{15}. Find nn.

The product is nd(n)/2n^{d(n)/2}, so nn uses only the primes 22 and 33: say n=2a3bn = 2^a 3^b and d=(a+1)(b+1)d = (a+1)(b+1). Comparing exponents, ad2=30\dfrac{ad}{2} = 30 and bd2=15\dfrac{bd}{2} = 15, so a=2ba = 2b. Then bd2=15\dfrac{bd}{2} = 15 becomes b(2b+1)(b+1)=30b(2b + 1)(b + 1) = 30, and b=2b = 2 works: 2⋅5⋅3=302 \cdot 5 \cdot 3 = 30. So a=4a = 4 and n=24⋅32=144n = 2^4 \cdot 3^2 = 144.

Common mistake

The divisor-count formula uses exponent plus one, and it needs the full prime factorization. A common slip is factoring 720720 as 8⋅908 \cdot 90 and multiplying divisor counts: d(8)⋅d(90)=4⋅12=48d(8) \cdot d(90) = 4 \cdot 12 = 48, but d(720)=30d(720) = 30. You can only multiply dd (or σ\sigma) across factors that share no prime.

Tip

σ(n)\sigma(n) is odd exactly when every odd prime appears to an even power: then each factor 1+p+⋯+pa1 + p + \dots + p^{a} for an odd pp has an odd number of odd terms. The factor for p=2p = 2 is always odd. So σ(n)\sigma(n) is odd exactly when nn is a perfect square or twice a perfect square.

Practice

Practice 1

How many positive divisors of 10,800=24⋅33⋅5210{,}800 = 2^4 \cdot 3^3 \cdot 5^2 are perfect squares?

Practice 2

How many positive divisors of 6106^{10} are multiples of 676^7?

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

Practice 3

What is the sum of all the positive odd divisors of 18001800?

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

Practice 4

What is the smallest positive integer that has exactly 1818 positive divisors?

Practice 5

How many ordered pairs of positive integers (a,b)(a, b) satisfy gcd⁡(a,b)=12\gcd(a, b) = 12 and lcm⁡(a,b)=2520\operatorname{lcm}(a, b) = 2520?

Practice 6

A positive integer NN has only 22 and 33 as prime factors. NN has exactly 3030 positive divisors and 6N6N has exactly 4242. How many positive divisors does N2N^2 have?

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

Practice 7

The product of all the positive divisors of nn is n12n^{12}, and n=2a⋅3bn = 2^a \cdot 3^b for positive integers aa and bb. What is the smallest possible value of nn?

Practice 8

For how many positive integers n≤50n \le 50 is the sum of the positive divisors of nn odd?

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

Real contest practice