What are the divisors of 666?

1, 2, 3, 6, 9, 18, 37, 74, 111, 222, 333, 666

6 even divisors

2, 6, 18, 74, 222, 666

6 odd divisors

1, 3, 9, 37, 111, 333

How to compute the divisors of 666?

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 666 by each of the numbers from 1 to 666 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)

  • 666 / 1 = 666 (the remainder is 0, so 1 is a divisor of 666)
  • 666 / 2 = 333 (the remainder is 0, so 2 is a divisor of 666)
  • 666 / 3 = 222 (the remainder is 0, so 3 is a divisor of 666)
  • ...
  • 666 / 665 = 1.0015037593985 (the remainder is 1, so 665 is not a divisor of 666)
  • 666 / 666 = 1 (the remainder is 0, so 666 is a divisor of 666)

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 666 (i.e. 25.806975801128). 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 )

  • 666 / 1 = 666 (the remainder is 0, so 1 and 666 are divisors of 666)
  • 666 / 2 = 333 (the remainder is 0, so 2 and 333 are divisors of 666)
  • 666 / 3 = 222 (the remainder is 0, so 3 and 222 are divisors of 666)
  • ...
  • 666 / 24 = 27.75 (the remainder is 18, so 24 is not a divisor of 666)
  • 666 / 25 = 26.64 (the remainder is 16, so 25 is not a divisor of 666)