What are the divisors of 5112?

1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 71, 72, 142, 213, 284, 426, 568, 639, 852, 1278, 1704, 2556, 5112

18 even divisors

2, 4, 6, 8, 12, 18, 24, 36, 72, 142, 284, 426, 568, 852, 1278, 1704, 2556, 5112

6 odd divisors

1, 3, 9, 71, 213, 639

How to compute the divisors of 5112?

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

  • 5112 / 1 = 5112 (the remainder is 0, so 1 is a divisor of 5112)
  • 5112 / 2 = 2556 (the remainder is 0, so 2 is a divisor of 5112)
  • 5112 / 3 = 1704 (the remainder is 0, so 3 is a divisor of 5112)
  • ...
  • 5112 / 5111 = 1.0001956564273 (the remainder is 1, so 5111 is not a divisor of 5112)
  • 5112 / 5112 = 1 (the remainder is 0, so 5112 is a divisor of 5112)

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 5112 (i.e. 71.498251726878). 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 )

  • 5112 / 1 = 5112 (the remainder is 0, so 1 and 5112 are divisors of 5112)
  • 5112 / 2 = 2556 (the remainder is 0, so 2 and 2556 are divisors of 5112)
  • 5112 / 3 = 1704 (the remainder is 0, so 3 and 1704 are divisors of 5112)
  • ...
  • 5112 / 70 = 73.028571428571 (the remainder is 2, so 70 is not a divisor of 5112)
  • 5112 / 71 = 72 (the remainder is 0, so 71 and 72 are divisors of 5112)