What are the divisors of 540?

1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 45, 54, 60, 90, 108, 135, 180, 270, 540

16 even divisors

2, 4, 6, 10, 12, 18, 20, 30, 36, 54, 60, 90, 108, 180, 270, 540

8 odd divisors

1, 3, 5, 9, 15, 27, 45, 135

How to compute the divisors of 540?

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

  • 540 / 1 = 540 (the remainder is 0, so 1 is a divisor of 540)
  • 540 / 2 = 270 (the remainder is 0, so 2 is a divisor of 540)
  • 540 / 3 = 180 (the remainder is 0, so 3 is a divisor of 540)
  • ...
  • 540 / 539 = 1.0018552875696 (the remainder is 1, so 539 is not a divisor of 540)
  • 540 / 540 = 1 (the remainder is 0, so 540 is a divisor of 540)

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 540 (i.e. 23.237900077245). 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 )

  • 540 / 1 = 540 (the remainder is 0, so 1 and 540 are divisors of 540)
  • 540 / 2 = 270 (the remainder is 0, so 2 and 270 are divisors of 540)
  • 540 / 3 = 180 (the remainder is 0, so 3 and 180 are divisors of 540)
  • ...
  • 540 / 22 = 24.545454545455 (the remainder is 12, so 22 is not a divisor of 540)
  • 540 / 23 = 23.478260869565 (the remainder is 11, so 23 is not a divisor of 540)