PYQ Vault

CDS Mathematics · Number System

Factors, Divisor Counting & Trailing Zeros

Everything you can read off a number's prime factorisation — how many divisors it has, what they sum to, how many are odd, and how many zeros a factorial or a big product ends in.

Why this matters

Twenty PYQs, four HARD. The whole unit runs on one move: write the number as a product of prime powers, then read the answer off the exponents. Counting the fives in a factorial appears six times across the chapter and is the most reliably tested single technique here.

Concept 1 of 6

Canonical prime-power form

Intuition

Before you can count anything about a number's divisors you must see it as prime powers. Everything downstream — divisor count, divisor sum, trailing zeros — is a function of the exponents alone, so getting the factorisation right is the whole job.

Definition

Write N=p1a1p2a2pkakN = p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k} with distinct primes pip_i.

  • A divisor of NN is exactly a product p1b1pkbkp_1^{b_1}\cdots p_k^{b_k} with 0biai0 \le b_i \le a_i.
  • Evaluate before factorising when the number is given as an expression: compute the value first, then factorise it, because an expression's terms rarely share the factorisation of their difference.
  • Collect repeated primes: 126=(223)6=2123612^6 = (2^2\cdot3)^6 = 2^{12}3^{6}, which then merges with any other power of 3.

Canonical form

N=p1a1p2a2pkakN = p_1^{a_1}\,p_2^{a_2}\cdots p_k^{a_k}

Worked example

Write 1800 in canonical prime-power form.
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 1Number SystemMODERATE
What is the number of factors of 2431638324^3 - 16^3 - 8^3 ?

[Q48 · CDS (I) 2025 — Elementary Mathematics · 2025]

Evaluate the expression before you factorise it

For 2431638324^3-16^3-8^3 there is no shortcut identity — compute 138244096512=921613824-4096-512 = 9216 and factorise that as 210322^{10}\cdot 3^2. Students who try to factor term by term and subtract exponents get nonsense, because exponents do not subtract across a difference.

Concept 2 of 6

Counting the divisors of a number

Intuition

Building a divisor means choosing an exponent for each prime, independently. For pap^a there are a+1a+1 choices (0 up to aa), so the total count is the product of all the (ai+1)(a_i+1).

Definition

If N=p1a1pkakN = p_1^{a_1}\cdots p_k^{a_k} then the number of positive divisors is

d(N)=(a1+1)(a2+1)(ak+1).d(N) = (a_1+1)(a_2+1)\cdots(a_k+1).

  • The count includes 1 and NN; subtract 2 when the question excludes them.
  • dd is multiplicative on coprime parts: d(mn)=d(m)d(n)d(mn)=d(m)d(n) when gcd(m,n)=1\gcd(m,n)=1.
  • d(N)d(N) is odd exactly when NN is a perfect square, since every exponent is then even.

Divisor count

d(N)=i=1k(ai+1)d(N)=\prod_{i=1}^{k}(a_i+1)
  • a_ithe exponent of the i-th prime in N

Worked example

How many positive divisors does 720 have?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 2Number SystemMODERATE
The number of divisors of the number 38808, exclusive of the divisors 1 and itself, is

[Q7 · CDS (II) 2018 — Elementary Mathematics · 2018]

Read whether 1 and N are to be excluded

d(38808)=72d(38808)=72, but the question asks for divisors "exclusive of 1 and itself", so the answer is 70. The same trap runs on 1000: d=16d=16, answer 14. The formula always counts both ends — the subtraction is yours to do.

Concept 3 of 6

Summing the divisors of a number

Intuition

Expanding the product (1+p+p2+)(1+q+q2+)(1+p+p^2+\cdots)(1+q+q^2+\cdots) generates every divisor exactly once, so the product of those geometric sums is the sum of the divisors.

Definition

For N=p1a1pkakN = p_1^{a_1}\cdots p_k^{a_k},

σ(N)=i=1k(1+pi+pi2++piai)=i=1kpiai+11pi1.\sigma(N) = \prod_{i=1}^{k}\left(1+p_i+p_i^{2}+\cdots+p_i^{a_i}\right) = \prod_{i=1}^{k}\frac{p_i^{a_i+1}-1}{p_i-1}.

  • For a single prime power the sum is a geometric series, so σ(2n)=2n+11\sigma(2^n)=2^{n+1}-1.
  • Like dd, σ\sigma is multiplicative on coprime parts.

Divisor sum

σ(N)=i=1kpiai+11pi1\sigma(N)=\prod_{i=1}^{k}\frac{p_i^{a_i+1}-1}{p_i-1}

Worked example

What is the sum of all divisors of 60?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 3Number SystemEASY
What is the sum of all the divisors of 256 ?

[Q27 · CDS (I) 2026 — Elementary Mathematics · 2026]

The divisor sum is a product of sums, not a sum of products

For 22352^2\cdot 3\cdot 5 the answer is (1+2+4)(1+3)(1+5)(1+2+4)(1+3)(1+5), not (1+2+4)+(1+3)+(1+5)(1+2+4)+(1+3)+(1+5). Multiplying the brackets is what generates each divisor once; adding them counts almost nothing correctly.

Concept 4 of 6

Odd divisors, divisors of a square, and working backwards

Intuition

Once the exponent formula is in hand, the variants are all small edits to it: drop the prime 2 to count odd divisors, double every exponent to count divisors of N2N^2, and factorise the divisor count to work backwards to the shape of NN.

Definition

From N=2amN = 2^{a}m with mm odd:

  • Odd divisors: d(m)d(m) — ignore the power of 2 entirely.
  • Even divisors: d(N)d(m)d(N) - d(m).
  • Divisors of N2N^{2}: every exponent doubles, so d(N2)=(2ai+1)d(N^2)=\prod(2a_i+1), always odd.
  • Backwards: a given d(N)d(N) factorises into the (ai+1)(a_i+1) terms, so d(N)=15=15d(N)=15=15 or 3×53\times5 means N=p14N=p^{14} or N=p4q2N=p^{4}q^{2}. Size constraints then pick the shape.
  • Ordered triples with abc=Nabc=N: distribute each prime power among the three slots independently.

Divisors of a square

d(N2)=i=1k(2ai+1)d(N^{2})=\prod_{i=1}^{k}(2a_i+1)

Worked example

How many odd divisors does 480 have, and how many even?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 4Number SystemMODERATE
Consider the number N=126×38×53N = 12^6 \times 3^8 \times 5^3. Which of the following statements is/are correct ? 1. The number of odd factors of N is 60. 2. The number of even factors of N is 720. Select the correct answer using the code given below :

[Q21 · CDS (II) 2022 — Elementary Mathematics · 2022]

Working backwards from a divisor count usually leaves several shapes

d(N)=15d(N)=15 admits p14p^{14} and p4q2p^{4}q^{2}. What eliminates the first is the size clue: the smallest p14p^{14} is 214=163842^{14}=16384, which has five digits, so a four-digit NN must be p4q2p^4q^2. Always list every factorisation of the count, then use the stated size to cut.

Concept 5 of 6

Counting the zeros at the end of a factorial

Intuition

A trailing zero needs a factor of 10, that is a 2 paired with a 5. In a factorial the twos hugely outnumber the fives, so the number of trailing zeros is just how many fives the factorial contains — and multiples of 25 contribute two fives, not one.

Definition

The number of trailing zeros of n!n! is

n5+n25+n125+\left\lfloor \frac{n}{5}\right\rfloor + \left\lfloor \frac{n}{25}\right\rfloor + \left\lfloor \frac{n}{125}\right\rfloor + \cdots

  • Each term counts the numbers up to nn carrying at least that many fives, so the powers add up correctly without double counting.
  • Stop when the divisor exceeds nn.
  • The same sum with 5 replaced by any prime pp gives the exponent of pp in n!n!, which is how you handle a divisor like 100n=22n52n100^{n}=2^{2n}5^{2n}.

Zeros at the end of n factorial

Z(n!)=i1n5iZ(n!)=\sum_{i\ge 1}\left\lfloor \frac{n}{5^{i}}\right\rfloor

Worked example

How many zeros does 50!50! end in?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 5Number SystemMODERATE
What is the largest power of 10 that divides the product 1×2×3×4×23×24×251 \times 2 \times 3 \times 4 \ldots \times 23 \times 24 \times 25 ?

[Q83 · CDS (I) 2018 — Elementary Mathematics · 2018]

Counting only the multiples of 5 undercounts

For 25!25! the multiples of 5 number 5, which tempts the answer 10510^5. But 25 itself carries two fives, so the true count is 5+1=65+1=6. Every term n/25\lfloor n/25\rfloor, n/125\lfloor n/125\rfloor is a real contribution, not a refinement you can skip.

Concept 6 of 6

Trailing zeros of a general product: the scarcer prime wins

Intuition

Away from factorials the twos are not guaranteed to outnumber the fives, so you must count both and take the smaller. Each factor of 10 needs one of each, so the scarcer prime caps the number of zeros.

Definition

For any product PP, the largest nn with 10nP10^{n} \mid P is

n=min(v2(P),  v5(P)),n = \min\big(v_2(P),\; v_5(P)\big),
where vpv_p is the total exponent of pp in PP.

  • Expand every composite base first: 759=(352)9=3951875^9 = (3\cdot 5^2)^9 = 3^9 5^{18}.
  • In a weighted product like 150×249××5011^{50}\times 2^{49}\times\cdots\times 50^{1}, each term's exponent multiplies its contribution.
  • Parity is a shortcut worth trying first: a sum or difference that is odd has no trailing zero at all, whatever its factors look like.

Zeros of a general product

n=min(v2(P),v5(P))n=\min\big(v_2(P),\,v_5(P)\big)

Worked example

What is the largest nn such that 10n10^{n} divides 28×53×72^{8}\times 5^{3}\times 7?
Practice this conceptself-check · 4 quick reps

From the bank · past-year question

Example 6Number SystemMODERATE
If 10n10^n divides 623×759×10526^{23} \times 75^9 \times 105^2, then what is the largest value of nn ?

[Q86 · CDS (I) 2019 — Elementary Mathematics · 2019]

Outside a factorial, do not assume the fives are the scarce prime

In n!n! the twos always outnumber the fives, so counting fives suffices. In 285372^{8}\cdot 5^{3}\cdot 7 it is the other way round, and in 62375910526^{23}\cdot75^{9}\cdot105^{2} the counts are 23 twos against 20 fives — close enough that guessing loses the mark. Count both, every time.

Check the parity of a SUM before counting any factors

For P+QP+Q where PP is a product of odd numbers and QQ of even ones, the sum is odd, so it ends in no zero at all — and no amount of counting fives inside PP and QQ is relevant. The 2026 question is exactly this shape, and the factor-counting route wastes minutes before failing.

Summary — formulas & gotchas at a glance

A revision cheat-sheet for the formulas and gotchas above. Click any concept name to jump back to its full explanation.

Formulas (6)

Watch out for (7)

Drill every past-year question on this subtopic

20 questions from the bank — paginated, with cart and Word-export support.

Related notes