What are the divisors of 1278?

1, 2, 3, 6, 9, 18, 71, 142, 213, 426, 639, 1278

6 even divisors

2, 6, 18, 142, 426, 1278

6 odd divisors

1, 3, 9, 71, 213, 639

How to compute the divisors of 1278?

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

  • 1278 / 1 = 1278 (the remainder is 0, so 1 is a divisor of 1278)
  • 1278 / 2 = 639 (the remainder is 0, so 2 is a divisor of 1278)
  • 1278 / 3 = 426 (the remainder is 0, so 3 is a divisor of 1278)
  • ...
  • 1278 / 1277 = 1.0007830853563 (the remainder is 1, so 1277 is not a divisor of 1278)
  • 1278 / 1278 = 1 (the remainder is 0, so 1278 is a divisor of 1278)

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 1278 (i.e. 35.749125863439). 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 )

  • 1278 / 1 = 1278 (the remainder is 0, so 1 and 1278 are divisors of 1278)
  • 1278 / 2 = 639 (the remainder is 0, so 2 and 639 are divisors of 1278)
  • 1278 / 3 = 426 (the remainder is 0, so 3 and 426 are divisors of 1278)
  • ...
  • 1278 / 34 = 37.588235294118 (the remainder is 20, so 34 is not a divisor of 1278)
  • 1278 / 35 = 36.514285714286 (the remainder is 18, so 35 is not a divisor of 1278)