What are the divisors of 20?
1, 2, 4, 5, 10, 20
- There is a total of 6 positive divisors.
- The sum of these divisors is 42.
- The arithmetic mean is 7.
4 even divisors
2, 4, 10, 20
2 odd divisors
1, 5
How to compute the divisors of 20?
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 20 by each of the numbers from 1 to 20 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 20 / 1 = 20 (the remainder is 0, so 1 is a divisor of 20)
- 20 / 2 = 10 (the remainder is 0, so 2 is a divisor of 20)
- 20 / 3 = 6.6666666666667 (the remainder is 2, so 3 is not a divisor of 20)
- ...
- 20 / 4 = 5 (the remainder is 0, so 4 is a divisor of 20)
- 20 / 5 = 4 (the remainder is 0, so 5 is a divisor of 20)
- 20 / 6 = 3.3333333333333 (the remainder is 2, so 6 is not a divisor of 20)
- 20 / 7 = 2.8571428571429 (the remainder is 6, so 7 is not a divisor of 20)
- 20 / 8 = 2.5 (the remainder is 4, so 8 is not a divisor of 20)
- 20 / 9 = 2.2222222222222 (the remainder is 2, so 9 is not a divisor of 20)
- 20 / 10 = 2 (the remainder is 0, so 10 is a divisor of 20)
- 20 / 11 = 1.8181818181818 (the remainder is 9, so 11 is not a divisor of 20)
- 20 / 12 = 1.6666666666667 (the remainder is 8, so 12 is not a divisor of 20)
- 20 / 13 = 1.5384615384615 (the remainder is 7, so 13 is not a divisor of 20)
- 20 / 14 = 1.4285714285714 (the remainder is 6, so 14 is not a divisor of 20)
- 20 / 15 = 1.3333333333333 (the remainder is 5, so 15 is not a divisor of 20)
- 20 / 16 = 1.25 (the remainder is 4, so 16 is not a divisor of 20)
- 20 / 17 = 1.1764705882353 (the remainder is 3, so 17 is not a divisor of 20)
- 20 / 18 = 1.1111111111111 (the remainder is 2, so 18 is not a divisor of 20)
- 20 / 19 = 1.0526315789474 (the remainder is 1, so 19 is not a divisor of 20)
- 20 / 20 = 1 (the remainder is 0, so 20 is a divisor of 20)
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 20 (i.e. 4.4721359549996). 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 )
- 20 / 1 = 20 (the remainder is 0, so 1 and 20 are divisors of 20)
- 20 / 2 = 10 (the remainder is 0, so 2 and 10 are divisors of 20)
- 20 / 3 = 6.6666666666667 (the remainder is 2, so 3 is not a divisor of 20)
- ...
- 20 / 4 = 5 (the remainder is 0, so 4 and 5 are divisors of 20)