What are the divisors of 1002?
1, 2, 3, 6, 167, 334, 501, 1002
- There is a total of 8 positive divisors.
- The sum of these divisors is 2016.
- The arithmetic mean is 252.
4 even divisors
2, 6, 334, 1002
4 odd divisors
1, 3, 167, 501
How to compute the divisors of 1002?
A number N is said to be divisible by a number M (with M non-zero) if, when we divide N by M, the remainder of the division is zero.
Brute force algorithm
We could start by using a brute-force method which would involve dividing 1002 by each of the numbers from 1 to 1002 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 1002 / 1 = 1002 (the remainder is 0, so 1 is a divisor of 1002)
- 1002 / 2 = 501 (the remainder is 0, so 2 is a divisor of 1002)
- 1002 / 3 = 334 (the remainder is 0, so 3 is a divisor of 1002)
- ...
- 1002 / 1001 = 1.000999000999 (the remainder is 1, so 1001 is not a divisor of 1002)
- 1002 / 1002 = 1 (the remainder is 0, so 1002 is a divisor of 1002)
Improved algorithm using square-root
However, there is another slightly better approach that reduces the number of iterations by testing only integers less than or equal to the square root of 1002 (i.e. 31.654383582689). Indeed, if a number N has a divisor D greater than its square root, then there is necessarily a smaller divisor d such that:
(thus, if , then )
- 1002 / 1 = 1002 (the remainder is 0, so 1 and 1002 are divisors of 1002)
- 1002 / 2 = 501 (the remainder is 0, so 2 and 501 are divisors of 1002)
- 1002 / 3 = 334 (the remainder is 0, so 3 and 334 are divisors of 1002)
- ...
- 1002 / 30 = 33.4 (the remainder is 12, so 30 is not a divisor of 1002)
- 1002 / 31 = 32.322580645161 (the remainder is 10, so 31 is not a divisor of 1002)