What are the divisors of 28?
1, 2, 4, 7, 14, 28
- There is a total of 6 positive divisors.
- The sum of these divisors is 56.
- The arithmetic mean is 9.3333333333333.
4 even divisors
2, 4, 14, 28
2 odd divisors
1, 7
How to compute the divisors of 28?
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 28 by each of the numbers from 1 to 28 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 28 / 1 = 28 (the remainder is 0, so 1 is a divisor of 28)
- 28 / 2 = 14 (the remainder is 0, so 2 is a divisor of 28)
- 28 / 3 = 9.3333333333333 (the remainder is 1, so 3 is not a divisor of 28)
- ...
- 28 / 27 = 1.037037037037 (the remainder is 1, so 27 is not a divisor of 28)
- 28 / 28 = 1 (the remainder is 0, so 28 is a divisor of 28)
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 28 (i.e. 5.2915026221292). 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 )
- 28 / 1 = 28 (the remainder is 0, so 1 and 28 are divisors of 28)
- 28 / 2 = 14 (the remainder is 0, so 2 and 14 are divisors of 28)
- 28 / 3 = 9.3333333333333 (the remainder is 1, so 3 is not a divisor of 28)
- ...
- 28 / 4 = 7 (the remainder is 0, so 4 and 7 are divisors of 28)
- 28 / 5 = 5.6 (the remainder is 3, so 5 is not a divisor of 28)