Finding the Number of Factors
of a Natural Number
David W. Hansen
© 2008
How does one go about finding all the factors of a natural number N? For small numbers, we simply factor N into its prime factors, and then take all possible combinations of these prime factors to determine its factors. Let’s consider natural numbers which are powers of a single prime.
(Note: In what follows, n1 = n1, n2 = n2, . . . , nk = nk)
For N = 73, we get factors of 7, 72, and 73 (3 factors), and, of course, a factor of 1 [73 = 1(73)]
(1 factor), for a total T of 3 + 1 = 4 factors.
For N = 135, we get factors of 13, 132, 133, 134, and 135 (5 factors), and, of course, a factor of 1
(1 factor), for a total T of 5 + 1 = 6 factors.
For N = pn1, we get factors of p, p2, p3 . . . pn1 (n1 factors), and, of course, a factor of 1
(1 factor), for a total T of n1 + 1 factors. Thus,
The number of factors T of a natural number N = pn1, where p is prime, is given by T = n1 + 1.
Let’s now consider natural numbers which are the products of powers of two primes.
To find all of the factors of N = p5q2, we select first all of the possible powers of each of the primes p and q taken one at a time (p, p2, p3, p4, p5 and q, q2), giving us a total of 5 + 2 = 7 factors. Then, we select all of the possible products of the powers of the primes p and q taken two at a time, namely
pq and pq2, p2q and p2q2, p3q and p3q2, p4q and p4q2, p5q and p5q2,
giving us 5 groups of 2 factors each for a total of 5(2) = 10 more factors. Counting the factor 1, this gives us a grand total T of 5 + 2 + 5(2) + 1 = 18 factors.
To find all of the factors of N = pn1qn2 , we select first all of the possible powers of each of the primes p and q taken one at a time (p, p2 . . . pn1 and q, q2 . . . qn2), giving us n1 + n2 factors. Then, we select all of the possible products of the powers of the primes p and q taken two at a time
pq, pq2 . . . pqn2 and p2q, p2q2 . . . p2qn2 , and . . . and pn1q, pn1q2 . . . pn1qn2,
giving us n1 groups of n2 factors each for a total of n1n2 more factors. Counting the factor 1, this gives us a grand total T of n1 + n2 + n1n2 + 1 = (n1 + 1)(n2 + 1) factors. Thus,
The number of factors T of a natural number N = pn1qn2, where p and q are primes,
is given by T = (n1 + 1)(n2 + 1).
Let’s now consider natural numbers which are the products of powers of three primes.
To find all of the factors of N = pn1qn2sn3 , we select first all of the possible powers of each of the primes
p, q, and s taken one at a time ( p, p2 . . . pn1 and q, q2 . . . qn2 and s, s2 . . . sn3 ), giving us
n1 + n2 + n3 factors. (1)
Next, we select all of the possible products of the powers of the primes p, q, and s taken two at a time.
a) Starting first with the products of the powers of p and q, we have
pq, pq2 . . . pqn2 and p2q, p2q2 . . . p2qn2 , and . . . and pn1q, pn1q2 . . . pn1qn2,
giving us n1 groups of n2 factors each for a total of n1n2 factors.
b) Next, using the products of powers of p and s, we have
ps, ps2 . . . psn3 and p2s, p2s2 . . . p2sn3 , and . . . and pn1s, pn1s2 . . . pn1sn3,
giving us n1 groups of n3 factors each for a total of n1n3 factors.
c) Then, using the products of powers of q and s, we have
qs, qs2 . . . qsn3 and q2s, q2s2 . . . q2sn3 , and . . . and qn2s, qn2s2 . . . qn2sn3,
giving us n2 groups of n3 factors each for a total of n2n3 factors.
The total from a), b), and c) is n1n2 + n1n3 + n2n3 more factors. (2)
Finally, we select all of the possible products of the powers of the primes p, q, and s taken three at a
time. Since we have n1 choices for the powers of p, n2 choices for the powers of q, and n3 choices for the
powers of s, we then, by the fundamental principle of counting, will have n1n2n3 choices for the powers of
p, q, and s taken three at a time, giving us a total of n1n2n3 factors. (3)
Combining the totals from (1), (2), and (3), and counting the factor 1, we get a grand total T of
(n1 + n2 + n3) + (n1n2 + n1n3 + n2n3) + (n1n2n3) + 1 = (n1 + 1)(n2 + 1)(n3 + 1) factors. Thus,
The number of factors T of a natural number N = pn1 qn2 sn3, where p, q, and s are primes,
is given by T = (n1 + 1)(n2 + 1)(n3 + 1).
This, of course, may be generalized to
The number of factors of a natural number N = p1n1 p2n2 p3n3 . . . pknk, where p1, p2, . . . , pk
are primes, is given by T = (n1 + 1)(n2 + 1)(n3 + 1) . . . (nk + 1).
Example. How many factors does 720 have? Since 720 = 10(72) = 2(5)(8)(9) = 2(5)(23)(32) =
(24)(32)(51), its number of factors T is (4+1)(2+1)(1+1) = 5(3)(2) = 30. They are
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120,
144, 180, 240, 360, 720
The Details
From 24, 32, and 51 2, 4, 8, 16, 3, 9, 5
n1 + n2 + n3 = 4 + 2 + 1 = 7 factors
From 24(32) 2(3), 2(32), 22(3), 22(32), 23(3), 23(32), 24(3), 24(32)
6, 18, 12, 36, 24, 72, 48, 144
n1n2 = 4(2) = 8 factors
From 24(51) 2(5), 22(5), 23(5), 24(5)
10, 20, 40, 80
n1n3 = 4(1) = 4 factors
From 32(51) 3(5), 9(5)
15, 45
n2n3 = 2(1) = 2 factors
From 24(32)(51) 2(3)(51) 22(3)(51) 23(3)(51) 24(3)(51)
30, 60, 120, 240
2(32)(51) 22(32)(51) 23(32)(51) 24(32)(51)
90, 180, 360, 720
n1n2n3 = 4(2)(1) = 8 factors
And the factor 1 gives us 1 factor.
Total number of factors is 7 + 8 + 4 + 2 + 8 + 1 = 30 factors.
Example. Find the smallest natural number N which has exactly 24 factors.
Now, N = p1n1 p2n2 p3n3 . . . pknk, and to find N, we must find values for n1, n2, etc. so that N
will have exactly 24 factors. So T = 24, and from above, T = (n1+1)(n2+1) . . . (nk+1). If we factor
T = 24 as 8(3), then T = (n1+1)(n2+1) = 8(3), and we have
n1 + 1 = 8, and n2 + 1 = 3, giving us n1 = 7 and n2 = 2.
Then, for any primes p1 and p2, the natural number N = p17p22 will have exactly 24 factors.
To get the smallest N, we pick p1 = 2 and p2 = 3, the first two smallest primes, and we get
N = 2732 = 128(9) = 1,152. But, is this really the smallest N? Let's factor T = 24 as 24(1),
12(2), or 6(4), and see if we can't obtain a smaller one.
a) For T = (n1+1)(n2+1) = 24(1), we get n1 + 1 = 24, and n2 + 1 = 1. So, n1 = 23 and n2 = 0.
Thus, N = p123p20 = 22330 = 223 = 8,388,608, a very large number!
b) For T = (n1+1)(n2+1) = 12(2), we get n1 + 1 = 12, and n2 + 1 = 2. So, n1 = 11 and n2 = 1.
Thus, N = p111p21 = 21131 = 6,144, again a large number!
c) For T = (n1+1)(n2+1) = 6(4), we get n1 + 1 = 6, and n2 + 1 = 4. So, n1 = 5 and n2 = 3.
Thus, N = p15p23 = 2533 = 864, which is the smallest number so far.
d) We can also write 24 as 4(3)(2). Then, we get T = (n1+1)(n2+1)(n3+1) = 4(3)(2) with
n1 + 1 = 4, n2 + 1 = 3, and n3 + 1 = 2, giving us n1 = 3, n2 = 2, and n3 = 1. So,
N = 233251 = 360, which is the smallest natural number yet!
e) We can even write 24 as 2(2)(2)(3). Then, we get T = (n1+1)(n2+1)(n3+1)(n4+1) = 2(2)(2)(3)
with n1 + 1 = 2, n2 + 1 = 2, n3 + 1 = 2, and n4 + 1 = 3, giving us n1 = 1, n2 = 1, n3 = 1,
and n4 = 2. So, N = 21315172 = 1,470, but it is silly to put the largest exponent 2 on the largest
prime 7. Putting the exponent 2 on the smallest prime 2, we get N = 22315171 = 420, but this,
unfortunately, is larger than the 360 we obtained above.
We have examined all the possible ways of writing 24 as a product of two, three, or four primes, so
we may conclude that 360 is the smallest natural number which has 24 factors
References
[1] Beiler, Albert H., Recreations in the Theory of Numbers: The Queen of Mathematics Entertains,
2nd ed., New York: Dover Publications, Inc., pp. 7-8
Home
_________________________________________________________________________________