What are the divisors of 252?

1, 2, 3, 4, 6, 7, 9, 12, 14, 18, 21, 28, 36, 42, 63, 84, 126, 252

12 even divisors

2, 4, 6, 12, 14, 18, 28, 36, 42, 84, 126, 252

6 odd divisors

1, 3, 7, 9, 21, 63

How to compute the divisors of 252?

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

  • 252 / 1 = 252 (the remainder is 0, so 1 is a divisor of 252)
  • 252 / 2 = 126 (the remainder is 0, so 2 is a divisor of 252)
  • 252 / 3 = 84 (the remainder is 0, so 3 is a divisor of 252)
  • ...
  • 252 / 251 = 1.003984063745 (the remainder is 1, so 251 is not a divisor of 252)
  • 252 / 252 = 1 (the remainder is 0, so 252 is a divisor of 252)

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 252 (i.e. 15.874507866388). 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 )

  • 252 / 1 = 252 (the remainder is 0, so 1 and 252 are divisors of 252)
  • 252 / 2 = 126 (the remainder is 0, so 2 and 126 are divisors of 252)
  • 252 / 3 = 84 (the remainder is 0, so 3 and 84 are divisors of 252)
  • ...
  • 252 / 14 = 18 (the remainder is 0, so 14 and 18 are divisors of 252)
  • 252 / 15 = 16.8 (the remainder is 12, so 15 is not a divisor of 252)