What are the divisors of 312?

1, 2, 3, 4, 6, 8, 12, 13, 24, 26, 39, 52, 78, 104, 156, 312

12 even divisors

2, 4, 6, 8, 12, 24, 26, 52, 78, 104, 156, 312

4 odd divisors

1, 3, 13, 39

How to compute the divisors of 312?

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

  • 312 / 1 = 312 (the remainder is 0, so 1 is a divisor of 312)
  • 312 / 2 = 156 (the remainder is 0, so 2 is a divisor of 312)
  • 312 / 3 = 104 (the remainder is 0, so 3 is a divisor of 312)
  • ...
  • 312 / 311 = 1.0032154340836 (the remainder is 1, so 311 is not a divisor of 312)
  • 312 / 312 = 1 (the remainder is 0, so 312 is a divisor of 312)

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 312 (i.e. 17.663521732656). 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 )

  • 312 / 1 = 312 (the remainder is 0, so 1 and 312 are divisors of 312)
  • 312 / 2 = 156 (the remainder is 0, so 2 and 156 are divisors of 312)
  • 312 / 3 = 104 (the remainder is 0, so 3 and 104 are divisors of 312)
  • ...
  • 312 / 16 = 19.5 (the remainder is 8, so 16 is not a divisor of 312)
  • 312 / 17 = 18.352941176471 (the remainder is 6, so 17 is not a divisor of 312)