What are the divisors of 180?
1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180
- There is a total of 18 positive divisors.
- The sum of these divisors is 546.
- The arithmetic mean is 30.333333333333.
12 even divisors
2, 4, 6, 10, 12, 18, 20, 30, 36, 60, 90, 180
6 odd divisors
1, 3, 5, 9, 15, 45
How to compute the divisors of 180?
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 180 by each of the numbers from 1 to 180 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 180 / 1 = 180 (the remainder is 0, so 1 is a divisor of 180)
- 180 / 2 = 90 (the remainder is 0, so 2 is a divisor of 180)
- 180 / 3 = 60 (the remainder is 0, so 3 is a divisor of 180)
- ...
- 180 / 179 = 1.0055865921788 (the remainder is 1, so 179 is not a divisor of 180)
- 180 / 180 = 1 (the remainder is 0, so 180 is a divisor of 180)
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 180 (i.e. 13.416407864999). 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 )
- 180 / 1 = 180 (the remainder is 0, so 1 and 180 are divisors of 180)
- 180 / 2 = 90 (the remainder is 0, so 2 and 90 are divisors of 180)
- 180 / 3 = 60 (the remainder is 0, so 3 and 60 are divisors of 180)
- ...
- 180 / 12 = 15 (the remainder is 0, so 12 and 15 are divisors of 180)
- 180 / 13 = 13.846153846154 (the remainder is 11, so 13 is not a divisor of 180)