What are the divisors of 642?
1, 2, 3, 6, 107, 214, 321, 642
- There is a total of 8 positive divisors.
- The sum of these divisors is 1296.
- The arithmetic mean is 162.
4 even divisors
2, 6, 214, 642
4 odd divisors
1, 3, 107, 321
How to compute the divisors of 642?
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 642 by each of the numbers from 1 to 642 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 642 / 1 = 642 (the remainder is 0, so 1 is a divisor of 642)
- 642 / 2 = 321 (the remainder is 0, so 2 is a divisor of 642)
- 642 / 3 = 214 (the remainder is 0, so 3 is a divisor of 642)
- ...
- 642 / 641 = 1.0015600624025 (the remainder is 1, so 641 is not a divisor of 642)
- 642 / 642 = 1 (the remainder is 0, so 642 is a divisor of 642)
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 642 (i.e. 25.33771891864). 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 )
- 642 / 1 = 642 (the remainder is 0, so 1 and 642 are divisors of 642)
- 642 / 2 = 321 (the remainder is 0, so 2 and 321 are divisors of 642)
- 642 / 3 = 214 (the remainder is 0, so 3 and 214 are divisors of 642)
- ...
- 642 / 24 = 26.75 (the remainder is 18, so 24 is not a divisor of 642)
- 642 / 25 = 25.68 (the remainder is 17, so 25 is not a divisor of 642)