What are the divisors of 21?
1, 3, 7, 21
- There is a total of 4 positive divisors.
- The sum of these divisors is 32.
- The arithmetic mean is 8.
4 odd divisors
1, 3, 7, 21
How to compute the divisors of 21?
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 21 by each of the numbers from 1 to 21 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 21 / 1 = 21 (the remainder is 0, so 1 is a divisor of 21)
- 21 / 2 = 10.5 (the remainder is 1, so 2 is not a divisor of 21)
- 21 / 3 = 7 (the remainder is 0, so 3 is a divisor of 21)
- ...
- 21 / 4 = 5.25 (the remainder is 1, so 4 is not a divisor of 21)
- 21 / 5 = 4.2 (the remainder is 1, so 5 is not a divisor of 21)
- 21 / 6 = 3.5 (the remainder is 3, so 6 is not a divisor of 21)
- 21 / 7 = 3 (the remainder is 0, so 7 is a divisor of 21)
- 21 / 8 = 2.625 (the remainder is 5, so 8 is not a divisor of 21)
- 21 / 9 = 2.3333333333333 (the remainder is 3, so 9 is not a divisor of 21)
- 21 / 10 = 2.1 (the remainder is 1, so 10 is not a divisor of 21)
- 21 / 11 = 1.9090909090909 (the remainder is 10, so 11 is not a divisor of 21)
- 21 / 12 = 1.75 (the remainder is 9, so 12 is not a divisor of 21)
- 21 / 13 = 1.6153846153846 (the remainder is 8, so 13 is not a divisor of 21)
- 21 / 14 = 1.5 (the remainder is 7, so 14 is not a divisor of 21)
- 21 / 15 = 1.4 (the remainder is 6, so 15 is not a divisor of 21)
- 21 / 16 = 1.3125 (the remainder is 5, so 16 is not a divisor of 21)
- 21 / 17 = 1.2352941176471 (the remainder is 4, so 17 is not a divisor of 21)
- 21 / 18 = 1.1666666666667 (the remainder is 3, so 18 is not a divisor of 21)
- 21 / 19 = 1.1052631578947 (the remainder is 2, so 19 is not a divisor of 21)
- 21 / 20 = 1.05 (the remainder is 1, so 20 is not a divisor of 21)
- 21 / 21 = 1 (the remainder is 0, so 21 is a divisor of 21)
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 21 (i.e. 4.5825756949558). 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 )
- 21 / 1 = 21 (the remainder is 0, so 1 and 21 are divisors of 21)
- 21 / 2 = 10.5 (the remainder is 1, so 2 is not a divisor of 21)
- 21 / 3 = 7 (the remainder is 0, so 3 and 7 are divisors of 21)
- ...
- 21 / 4 = 5.25 (the remainder is 1, so 4 is not a divisor of 21)