What are the divisors of 240?
1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 40, 48, 60, 80, 120, 240
- There is a total of 20 positive divisors.
- The sum of these divisors is 744.
- The arithmetic mean is 37.2.
16 even divisors
2, 4, 6, 8, 10, 12, 16, 20, 24, 30, 40, 48, 60, 80, 120, 240
4 odd divisors
1, 3, 5, 15
How to compute the divisors of 240?
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 240 by each of the numbers from 1 to 240 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 240 / 1 = 240 (the remainder is 0, so 1 is a divisor of 240)
- 240 / 2 = 120 (the remainder is 0, so 2 is a divisor of 240)
- 240 / 3 = 80 (the remainder is 0, so 3 is a divisor of 240)
- ...
- 240 / 239 = 1.0041841004184 (the remainder is 1, so 239 is not a divisor of 240)
- 240 / 240 = 1 (the remainder is 0, so 240 is a divisor of 240)
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 240 (i.e. 15.49193338483). 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 )
- 240 / 1 = 240 (the remainder is 0, so 1 and 240 are divisors of 240)
- 240 / 2 = 120 (the remainder is 0, so 2 and 120 are divisors of 240)
- 240 / 3 = 80 (the remainder is 0, so 3 and 80 are divisors of 240)
- ...
- 240 / 14 = 17.142857142857 (the remainder is 2, so 14 is not a divisor of 240)
- 240 / 15 = 16 (the remainder is 0, so 15 and 16 are divisors of 240)