What are the divisors of 324?

1, 2, 3, 4, 6, 9, 12, 18, 27, 36, 54, 81, 108, 162, 324

10 even divisors

2, 4, 6, 12, 18, 36, 54, 108, 162, 324

5 odd divisors

1, 3, 9, 27, 81

How to compute the divisors of 324?

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

  • 324 / 1 = 324 (the remainder is 0, so 1 is a divisor of 324)
  • 324 / 2 = 162 (the remainder is 0, so 2 is a divisor of 324)
  • 324 / 3 = 108 (the remainder is 0, so 3 is a divisor of 324)
  • ...
  • 324 / 323 = 1.0030959752322 (the remainder is 1, so 323 is not a divisor of 324)
  • 324 / 324 = 1 (the remainder is 0, so 324 is a divisor of 324)

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 324 (i.e. 18). 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 )

  • 324 / 1 = 324 (the remainder is 0, so 1 and 324 are divisors of 324)
  • 324 / 2 = 162 (the remainder is 0, so 2 and 162 are divisors of 324)
  • 324 / 3 = 108 (the remainder is 0, so 3 and 108 are divisors of 324)
  • ...
  • 324 / 17 = 19.058823529412 (the remainder is 1, so 17 is not a divisor of 324)
  • 324 / 18 = 18 (the remainder is 0, so 18 and 18 are divisors of 324)