What are the divisors of 1218?

1, 2, 3, 6, 7, 14, 21, 29, 42, 58, 87, 174, 203, 406, 609, 1218

8 even divisors

2, 6, 14, 42, 58, 174, 406, 1218

8 odd divisors

1, 3, 7, 21, 29, 87, 203, 609

How to compute the divisors of 1218?

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.

N mod M = 0

Brute force algorithm

We could start by using a brute-force method which would involve dividing 1218 by each of the numbers from 1 to 1218 to determine which ones have a remainder equal to 0.

Remainder = N ( M × N M )

(where N M is the integer part of the quotient)

  • 1218 / 1 = 1218 (the remainder is 0, so 1 is a divisor of 1218)
  • 1218 / 2 = 609 (the remainder is 0, so 2 is a divisor of 1218)
  • 1218 / 3 = 406 (the remainder is 0, so 3 is a divisor of 1218)
  • ...
  • 1218 / 1217 = 1.0008216926869 (the remainder is 1, so 1217 is not a divisor of 1218)
  • 1218 / 1218 = 1 (the remainder is 0, so 1218 is a divisor of 1218)

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 1218 (i.e. 34.89985673323). Indeed, if a number N has a divisor D greater than its square root, then there is necessarily a smaller divisor d such that:

D × d = N

(thus, if N D = d , then N d = D )

  • 1218 / 1 = 1218 (the remainder is 0, so 1 and 1218 are divisors of 1218)
  • 1218 / 2 = 609 (the remainder is 0, so 2 and 609 are divisors of 1218)
  • 1218 / 3 = 406 (the remainder is 0, so 3 and 406 are divisors of 1218)
  • ...
  • 1218 / 33 = 36.909090909091 (the remainder is 30, so 33 is not a divisor of 1218)
  • 1218 / 34 = 35.823529411765 (the remainder is 28, so 34 is not a divisor of 1218)