• Practice
  • About 15 min
  • 5 practice questions

Divisors, factor pairs and trailing zeros: counting with prime factors

Count the divisors of a number from its prime factorisation, the odd, even and perfect-square divisors, the sum of the divisors and the ways of writing a number as a product of two factors, and find the number of trailing zeros in n!.

If something looks wrong, please tell us.

A number is a product of primes, so choosing a divisor means choosing, for each prime, how many times it appears. That turns divisor questions into counting problems with the multiplication principle.

The number of divisors

If N = p^a · q^b · r^c with primes p, q, r, then every divisor has the form p^i q^j r^k with 0 ≤ i ≤ a, 0 ≤ j ≤ b, 0 ≤ k ≤ c. There are a + 1 choices for i, b + 1 for j and c + 1 for k, so the number of divisors is (a + 1)(b + 1)(c + 1). The sum of all the divisors is (1 + p + … + p^a)(1 + q + … + q^b)(1 + r + … + r^c).

N = p^a q^b r^c has (a + 1)(b + 1)(c + 1) divisors. Add 1 to each exponent and multiply.

Worked example 1: the divisors of 360

Factorise: 360 = 2³ × 3² × 5. The number of divisors is (3 + 1)(2 + 1)(1 + 1) = 4 × 3 × 2 = 24. The odd divisors use no factor 2, so i = 0, leaving 3 × 2 = 6. The even divisors are the rest: 24 − 6 = 18. The sum of the divisors is (1 + 2 + 4 + 8)(1 + 3 + 9)(1 + 5) = 15 × 13 × 6 = 1 170. The sum of the odd divisors is 13 × 6 = 78. The divisors that are multiples of 3 need j ≥ 1: 4 × 2 × 2 = 16.

Perfect-square divisors

A divisor is a perfect square when all its exponents are even. For 360 = 2³ × 3² × 5¹, the exponent of 2 can be 0 or 2 (2 choices), the exponent of 3 can be 0 or 2 (2 choices), and the exponent of 5 can only be 0 (1 choice, because the exponent 1 is odd). The count is 2 × 2 × 1 = 4: the squares 1, 4, 9 and 36.

Worked example 2: products of two factors

In how many ways can 360 be written as a product of two factors? If order matters (2 × 180 differs from 180 × 2), each divisor d can be paired with 360/d, so there are 24 ordered pairs. If order does not matter, the pairs {d, 360/d} are counted twice each, except when d = 360/d, which happens only when 360 is a perfect square. Since 360 is not a perfect square, the number of unordered pairs is 24/2 = 12. For a perfect square such as 36 = 2² × 3², with 9 divisors, the number of unordered pairs is (9 + 1)/2 = 5: (1, 36), (2, 18), (3, 12), (4, 9), (6, 6).

Worked example 3: trailing zeros in n!

A trailing zero comes from a factor 10 = 2 × 5, and there are always more 2s than 5s in n!, so the number of zeros equals the exponent of 5 in n!. This is ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …, where ⌊ ⌋ means the integer part. For 100!: 100/5 = 20, 100/25 = 4, and 100/125 = 0, so there are 20 + 4 = 24 zeros. For 50!: 10 + 2 = 12. For 125!: 25 + 5 + 1 = 31. As a check on a small case, 25! = 15511210043330985984000000, which ends in 6 zeros, and ⌊25/5⌋ + ⌊25/25⌋ = 5 + 1 = 6.

Key takeaways: factorise first; the divisor count is the product of (exponent + 1); odd divisors drop the prime 2; square divisors need even exponents; unordered factor pairs are half of the divisors unless the number is a perfect square; zeros in n! are the powers of 5.

Check your understanding

  1. 1. How many divisors does 2520 = 2³ × 3² × 5 × 7 have?

    1. 48
    2. 24
    3. 36
    4. 20
    Show answer

    Answer: A. (3 + 1)(2 + 1)(1 + 1)(1 + 1) = 4 × 3 × 2 × 2 = 48.

  2. 2. How many odd divisors does 360 have?

    1. 18
    2. 12
    3. 6
    4. 24
    Show answer

    Answer: C. Remove the prime 2: the odd part is 3² × 5, which has (2 + 1)(1 + 1) = 6 divisors.

  3. 3. How many divisors of 1800 = 2³ × 3² × 5² are perfect squares?

    1. 12
    2. 8
    3. 36
    4. 9
    Show answer

    Answer: B. The exponent of 2 can be 0 or 2 (2 choices), of 3 can be 0 or 2 (2 choices) and of 5 can be 0 or 2 (2 choices): 2 × 2 × 2 = 8.

  4. 4. In how many ways can 360 be written as a product of two factors, if the order does not matter?

    1. 24
    2. 6
    3. 18
    4. 12
    Show answer

    Answer: D. 360 has 24 divisors, which pair up into 12 unordered pairs since 360 is not a perfect square.

  5. 5. How many trailing zeros does 100! have?

    1. 20
    2. 24
    3. 25
    4. 22
    Show answer

    Answer: B. ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24.

Privacy · Terms · Refunds · Delivery