What are the divisors of 340?
1, 2, 4, 5, 10, 17, 20, 34, 68, 85, 170, 340
- There is a total of 12 positive divisors.
- The sum of these divisors is 756.
- The arithmetic mean is 63.
8 even divisors
2, 4, 10, 20, 34, 68, 170, 340
4 odd divisors
1, 5, 17, 85
How to compute the divisors of 340?
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 340 by each of the numbers from 1 to 340 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 340 / 1 = 340 (the remainder is 0, so 1 is a divisor of 340)
- 340 / 2 = 170 (the remainder is 0, so 2 is a divisor of 340)
- 340 / 3 = 113.33333333333 (the remainder is 1, so 3 is not a divisor of 340)
- ...
- 340 / 339 = 1.0029498525074 (the remainder is 1, so 339 is not a divisor of 340)
- 340 / 340 = 1 (the remainder is 0, so 340 is a divisor of 340)
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 340 (i.e. 18.439088914586). 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 )
- 340 / 1 = 340 (the remainder is 0, so 1 and 340 are divisors of 340)
- 340 / 2 = 170 (the remainder is 0, so 2 and 170 are divisors of 340)
- 340 / 3 = 113.33333333333 (the remainder is 1, so 3 is not a divisor of 340)
- ...
- 340 / 17 = 20 (the remainder is 0, so 17 and 20 are divisors of 340)
- 340 / 18 = 18.888888888889 (the remainder is 16, so 18 is not a divisor of 340)