What are the divisors of 124?
1, 2, 4, 31, 62, 124
- There is a total of 6 positive divisors.
- The sum of these divisors is 224.
- The arithmetic mean is 37.333333333333.
4 even divisors
2, 4, 62, 124
2 odd divisors
1, 31
How to compute the divisors of 124?
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 124 by each of the numbers from 1 to 124 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 124 / 1 = 124 (the remainder is 0, so 1 is a divisor of 124)
- 124 / 2 = 62 (the remainder is 0, so 2 is a divisor of 124)
- 124 / 3 = 41.333333333333 (the remainder is 1, so 3 is not a divisor of 124)
- ...
- 124 / 123 = 1.0081300813008 (the remainder is 1, so 123 is not a divisor of 124)
- 124 / 124 = 1 (the remainder is 0, so 124 is a divisor of 124)
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 124 (i.e. 11.13552872566). 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 )
- 124 / 1 = 124 (the remainder is 0, so 1 and 124 are divisors of 124)
- 124 / 2 = 62 (the remainder is 0, so 2 and 62 are divisors of 124)
- 124 / 3 = 41.333333333333 (the remainder is 1, so 3 is not a divisor of 124)
- ...
- 124 / 10 = 12.4 (the remainder is 4, so 10 is not a divisor of 124)
- 124 / 11 = 11.272727272727 (the remainder is 3, so 11 is not a divisor of 124)