What are the divisors of 1018?
1, 2, 509, 1018
- There is a total of 4 positive divisors.
- The sum of these divisors is 1530.
- The arithmetic mean is 382.5.
2 even divisors
2, 1018
2 odd divisors
1, 509
How to compute the divisors of 1018?
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 1018 by each of the numbers from 1 to 1018 to determine which ones have a remainder equal to 0.
(where is the integer part of the quotient)
- 1018 / 1 = 1018 (the remainder is 0, so 1 is a divisor of 1018)
- 1018 / 2 = 509 (the remainder is 0, so 2 is a divisor of 1018)
- 1018 / 3 = 339.33333333333 (the remainder is 1, so 3 is not a divisor of 1018)
- ...
- 1018 / 1017 = 1.0009832841691 (the remainder is 1, so 1017 is not a divisor of 1018)
- 1018 / 1018 = 1 (the remainder is 0, so 1018 is a divisor of 1018)
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 1018 (i.e. 31.906112267088). 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 )
- 1018 / 1 = 1018 (the remainder is 0, so 1 and 1018 are divisors of 1018)
- 1018 / 2 = 509 (the remainder is 0, so 2 and 509 are divisors of 1018)
- 1018 / 3 = 339.33333333333 (the remainder is 1, so 3 is not a divisor of 1018)
- ...
- 1018 / 30 = 33.933333333333 (the remainder is 28, so 30 is not a divisor of 1018)
- 1018 / 31 = 32.838709677419 (the remainder is 26, so 31 is not a divisor of 1018)