What are the divisors of 118?
1, 2, 59, 118
- There is a total of 4 positive divisors.
- The sum of these divisors is 180.
- The arithmetic mean is 45.
2 even divisors
2, 118
2 odd divisors
1, 59
How to compute the divisors of 118?
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 118 by each of the numbers from 1 to 118 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 118 / 1 = 118 (the remainder is 0, so 1 is a divisor of 118)
- 118 / 2 = 59 (the remainder is 0, so 2 is a divisor of 118)
- 118 / 3 = 39.333333333333 (the remainder is 1, so 3 is not a divisor of 118)
- ...
- 118 / 117 = 1.008547008547 (the remainder is 1, so 117 is not a divisor of 118)
- 118 / 118 = 1 (the remainder is 0, so 118 is a divisor of 118)
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 118 (i.e. 10.8627804912). 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 )
- 118 / 1 = 118 (the remainder is 0, so 1 and 118 are divisors of 118)
- 118 / 2 = 59 (the remainder is 0, so 2 and 59 are divisors of 118)
- 118 / 3 = 39.333333333333 (the remainder is 1, so 3 is not a divisor of 118)
- ...
- 118 / 9 = 13.111111111111 (the remainder is 1, so 9 is not a divisor of 118)
- 118 / 10 = 11.8 (the remainder is 8, so 10 is not a divisor of 118)