What are the divisors of 342?
1, 2, 3, 6, 9, 18, 19, 38, 57, 114, 171, 342
- There is a total of 12 positive divisors.
- The sum of these divisors is 780.
- The arithmetic mean is 65.
6 even divisors
2, 6, 18, 38, 114, 342
6 odd divisors
1, 3, 9, 19, 57, 171
How to compute the divisors of 342?
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 342 by each of the numbers from 1 to 342 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 342 / 1 = 342 (the remainder is 0, so 1 is a divisor of 342)
- 342 / 2 = 171 (the remainder is 0, so 2 is a divisor of 342)
- 342 / 3 = 114 (the remainder is 0, so 3 is a divisor of 342)
- ...
- 342 / 341 = 1.0029325513196 (the remainder is 1, so 341 is not a divisor of 342)
- 342 / 342 = 1 (the remainder is 0, so 342 is a divisor of 342)
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 342 (i.e. 18.493242008907). 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 )
- 342 / 1 = 342 (the remainder is 0, so 1 and 342 are divisors of 342)
- 342 / 2 = 171 (the remainder is 0, so 2 and 171 are divisors of 342)
- 342 / 3 = 114 (the remainder is 0, so 3 and 114 are divisors of 342)
- ...
- 342 / 17 = 20.117647058824 (the remainder is 2, so 17 is not a divisor of 342)
- 342 / 18 = 19 (the remainder is 0, so 18 and 19 are divisors of 342)