What are the divisors of 31?
1, 31
- There is a total of 2 positive divisors.
- The sum of these divisors is 32.
- The arithmetic mean is 16.
2 odd divisors
1, 31
How to compute the divisors of 31?
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 31 by each of the numbers from 1 to 31 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 31 / 1 = 31 (the remainder is 0, so 1 is a divisor of 31)
- 31 / 2 = 15.5 (the remainder is 1, so 2 is not a divisor of 31)
- 31 / 3 = 10.333333333333 (the remainder is 1, so 3 is not a divisor of 31)
- ...
- 31 / 30 = 1.0333333333333 (the remainder is 1, so 30 is not a divisor of 31)
- 31 / 31 = 1 (the remainder is 0, so 31 is a divisor of 31)
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 31 (i.e. 5.56776436283). 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 )
- 31 / 1 = 31 (the remainder is 0, so 1 and 31 are divisors of 31)
- 31 / 2 = 15.5 (the remainder is 1, so 2 is not a divisor of 31)
- 31 / 3 = 10.333333333333 (the remainder is 1, so 3 is not a divisor of 31)
- ...
- 31 / 4 = 7.75 (the remainder is 3, so 4 is not a divisor of 31)
- 31 / 5 = 6.2 (the remainder is 1, so 5 is not a divisor of 31)