What are the divisors of 1020?

1, 2, 3, 4, 5, 6, 10, 12, 15, 17, 20, 30, 34, 51, 60, 68, 85, 102, 170, 204, 255, 340, 510, 1020

16 even divisors

2, 4, 6, 10, 12, 20, 30, 34, 60, 68, 102, 170, 204, 340, 510, 1020

8 odd divisors

1, 3, 5, 15, 17, 51, 85, 255

How to compute the divisors of 1020?

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

  • 1020 / 1 = 1020 (the remainder is 0, so 1 is a divisor of 1020)
  • 1020 / 2 = 510 (the remainder is 0, so 2 is a divisor of 1020)
  • 1020 / 3 = 340 (the remainder is 0, so 3 is a divisor of 1020)
  • ...
  • 1020 / 1019 = 1.0009813542689 (the remainder is 1, so 1019 is not a divisor of 1020)
  • 1020 / 1020 = 1 (the remainder is 0, so 1020 is a divisor of 1020)

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 1020 (i.e. 31.937438845343). 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 )

  • 1020 / 1 = 1020 (the remainder is 0, so 1 and 1020 are divisors of 1020)
  • 1020 / 2 = 510 (the remainder is 0, so 2 and 510 are divisors of 1020)
  • 1020 / 3 = 340 (the remainder is 0, so 3 and 340 are divisors of 1020)
  • ...
  • 1020 / 30 = 34 (the remainder is 0, so 30 and 34 are divisors of 1020)
  • 1020 / 31 = 32.903225806452 (the remainder is 28, so 31 is not a divisor of 1020)