Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 86 ยท Number System

Factors, Multiples and Counting Divisors

Use prime factorization to count factors, add them up, spot perfect squares and split numbers into pairs, with a runnable factor calculator.

Questions like "How many factors does 360 have?" or "In how many ways can 144 be written as a product of two numbers?" look like they need a long list. They do not. Once a number is written as a product of primes, its factors follow a simple pattern, and you can count them, add them and classify them in a few seconds.

This lesson builds on the idea of primes from Number Types and Divisibility Rules. You will learn prime factorization, the formulas for the number and sum of factors, how to recognize perfect squares, and how to handle the variations that appear in tests. A runnable calculator lets you check your own examples.

Prime factorization

Every integer greater than 1 can be written as a product of primes in exactly one way (apart from order). This is the fundamental theorem of arithmetic. We write it with exponents: 360 = 2 ร— 2 ร— 2 ร— 3 ร— 3 ร— 5 = 2ยณ ร— 3ยฒ ร— 5ยน.

To factorize, divide by the smallest prime that works, repeat, and move to the next prime when it no longer divides. Use the divisibility rules to choose quickly.

flowchart TB
    A["360"] --> B["2 x 180"]
    B --> C["2 x 90"]
    C --> D["2 x 45"]
    D --> E["3 x 15"]
    E --> F["3 x 5"]

Repeated division of 360 by the smallest working prime gives 2 ร— 2 ร— 2 ร— 3 ร— 3 ร— 5.

Counting factors

Take N = p^a ร— q^b ร— r^c, where p, q and r are distinct primes. Every factor of N has the form p^i ร— q^j ร— r^k where i can be 0 to a, j can be 0 to b and k can be 0 to c. That gives a + 1 choices, b + 1 choices and c + 1 choices, independent of each other. So:

number of factors = (a + 1)(b + 1)(c + 1)

For 360 = 2ยณ ร— 3ยฒ ร— 5ยน: (3 + 1)(2 + 1)(1 + 1) = 4 ร— 3 ร— 2 = 24 factors.

Variations follow from the same idea:

  • Odd factors: the power of 2 must be 0, so ignore the 2's. Odd factors of 360: (2 + 1)(1 + 1) = 6 (namely 1, 3, 5, 9, 15, 45).
  • Even factors: total minus odd, which is 24 โˆ’ 6 = 18. Equivalently, the power of 2 is at least 1, giving 3 choices for it: 3 ร— 3 ร— 2 = 18.
  • Factors that are multiples of a given number: divide first. Factors of 360 that are multiples of 6: write 360 = 6 ร— 60, and each such factor is 6 times a factor of 60 = 2ยฒ ร— 3 ร— 5, so (2 + 1)(1 + 1)(1 + 1) = 12.
  • Ways to write N as a product of two factors (order ignored): half the number of factors, if N is not a perfect square. For 360 that is 24 รท 2 = 12 pairs. If order matters, the answer is 24.

Sum of factors

Adding all the factors multiplies out nicely as a product of geometric sums:

sum of factors = (1 + p + โ€ฆ + p^a)(1 + q + โ€ฆ + q^b)(1 + r + โ€ฆ + r^c)

For 360: (1 + 2 + 4 + 8)(1 + 3 + 9)(1 + 5) = 15 ร— 13 ร— 6 = 1,170. The idea is the same as the counting argument: each factor picks one term from each bracket, and multiplying out the brackets lists every factor once.

A perfect number equals the sum of its proper divisors (all factors except itself), which means its factor sum is exactly 2N. The first two are 6 (1 + 2 + 3) and 28 (1 + 2 + 4 + 7 + 14).

Product of factors

The factors of N pair up as (d, N/d), and each pair multiplies to N. If N has F factors, there are F/2 pairs, so the product of all factors is N^(F/2). For 12, which has 6 factors (1, 2, 3, 4, 6, 12), the product is 12ยณ = 1,728. This also works for perfect squares, where the square root pairs with itself.

Perfect squares

A number is a perfect square exactly when every exponent in its prime factorization is even. 144 = 2โด ร— 3ยฒ is a square (12ยฒ). 360 = 2ยณ ร— 3ยฒ ร— 5 is not, because of the odd exponents on 2 and 5.

Two consequences matter a lot in aptitude tests:

  1. A perfect square has an odd number of factors, because every exponent a is even and so a + 1 is odd, and a product of odd numbers is odd. Non-squares have an even number of factors. This is the key to the classic "100 lockers" puzzle: locker k is toggled once per factor, so only lockers numbered by perfect squares end up open.
  2. Smallest multiplier to make a square: multiply by each prime that has an odd exponent. To make 360 a perfect square, multiply by 2 ร— 5 = 10, giving 3,600 = 60ยฒ. To make it a square by dividing, divide by the same product: 360 รท 10 = 36.

A square number can only end in 0, 1, 4, 5, 6 or 9, never in 2, 3, 7 or 8. That rules out many options immediately. Squares also leave remainder 0 or 1 when divided by 3, and 0 or 1 when divided by 4.

A factor calculator

The script below factorizes any number, counts and sums its factors, counts odd and even factors, tells you if it is a perfect square, and gives the smallest multiplier that makes it a square. It also verifies the formulas by brute-force listing.

JS Factor calculator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that for 144 the multiplier is 1 (it is already a square) and the number of factors is odd (15). For 1,001 = 7 ร— 11 ร— 13 there are 2 ร— 2 ร— 2 = 8 factors.

Multiples

A multiple of n is n ร— k for an integer k. Counting multiples in a range uses division:

  • Multiples of 7 between 1 and 100: โŒŠ100 รท 7โŒ‹ = 14.
  • Multiples of 7 between 100 and 200 (inclusive): โŒŠ200 รท 7โŒ‹ โˆ’ โŒŠ99 รท 7โŒ‹ = 28 โˆ’ 14 = 14.
  • Multiples of 4 or 6 up to 100: multiples of 4 (25) plus multiples of 6 (16), minus those counted twice, multiples of 12 (8): 25 + 16 โˆ’ 8 = 33. Note that you subtract the multiples of the LCM (12), not the product (24).

The trailing zeros of a product come from pairs of factors 2 and 5. For example, 20 ร— 15 ร— 25 = 2ยฒ ร— 5 ร— 3 ร— 5 ร— 5ยฒ has two 2's and four 5's, so it ends in only two zeros (the number of pairs is the smaller count).

Here is a second script to practice the multiples-in-a-range idea, together with an inclusion-exclusion check.

JS Count multiples in a range

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Worked examples

1. How many factors of 2โด ร— 3ยณ ร— 5ยฒ are perfect squares? A factor 2^i ร— 3^j ร— 5^k is a square when i, j, k are all even. Choices: i โˆˆ {0, 2, 4} (3), j โˆˆ {0, 2} (2), k โˆˆ {0, 2} (2). Answer: 3 ร— 2 ร— 2 = 12.

2. Find the smallest number with exactly 12 factors. Write 12 as a product of numbers (each is an exponent plus 1): 12, 6 ร— 2, 4 ร— 3 or 3 ร— 2 ร— 2. Assign the largest exponents to the smallest primes: 2ยนยน = 2,048; 2โต ร— 3 = 96; 2ยณ ร— 3ยฒ = 72; 2ยฒ ร— 3 ร— 5 = 60. The smallest is 60.

3. What is the sum of the odd factors of 360? Ignore the 2's: (1 + 3 + 9)(1 + 5) = 13 ร— 6 = 78.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. How many factors does 180 have?

    180 = 2^2 x 3^2 x 5, so the number of factors is (2+1)(2+1)(1+1) = 18.
  2. 2. What is the sum of all factors of 60?

    60 = 2^2 x 3 x 5, so the sum is (1+2+4)(1+3)(1+5) = 7 x 4 x 6 = 168.
  3. 3. By which smallest number should 1,350 be multiplied to make it a perfect square?

    1,350 = 2 x 3^3 x 5^2. The odd exponents belong to 2 (exponent 1) and 3 (exponent 3), so multiply by 2 x 3 = 6 to get 8,100 = 90^2.
  4. 4. In how many ways can 144 be written as a product of two factors, ignoring order?

    144 = 2^4 x 3^2 has 5 x 3 = 15 factors. It is a perfect square, so the pairs number (15 + 1) / 2 = 8, counting 12 x 12 as one way.
  5. 5. A number has an odd number of factors. What must be true?

    An odd count of factors means every (exponent + 1) is odd, so every exponent is even: the number is a perfect square.

Summary

  • Write N = p^a ร— q^b ร— โ€ฆ in primes; the number of factors is (a + 1)(b + 1)โ€ฆ.
  • The sum of factors is the product of geometric sums (1 + p + โ€ฆ + p^a).
  • Odd factors ignore the power of 2; even factors = total โˆ’ odd.
  • Perfect squares have all exponents even and an odd number of factors; fix a non-square by multiplying by its odd-exponent primes.
  • Product of factors is N^(F/2); pairs of factors multiply to N.
  • Count multiples in a range with floor division and use the LCM for "or" questions.

Next: HCF and LCM, where you will find the greatest common divisor and least common multiple and solve bells, tiles and rope problems.