What are the divisors of 1640?

1, 2, 4, 5, 8, 10, 20, 40, 41, 82, 164, 205, 328, 410, 820, 1640

12 even divisors

2, 4, 8, 10, 20, 40, 82, 164, 328, 410, 820, 1640

4 odd divisors

1, 5, 41, 205

How to compute the divisors of 1640?

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

  • 1640 / 1 = 1640 (the remainder is 0, so 1 is a divisor of 1640)
  • 1640 / 2 = 820 (the remainder is 0, so 2 is a divisor of 1640)
  • 1640 / 3 = 546.66666666667 (the remainder is 2, so 3 is not a divisor of 1640)
  • ...
  • 1640 / 1639 = 1.0006101281269 (the remainder is 1, so 1639 is not a divisor of 1640)
  • 1640 / 1640 = 1 (the remainder is 0, so 1640 is a divisor of 1640)

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 1640 (i.e. 40.496913462633). 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 )

  • 1640 / 1 = 1640 (the remainder is 0, so 1 and 1640 are divisors of 1640)
  • 1640 / 2 = 820 (the remainder is 0, so 2 and 820 are divisors of 1640)
  • 1640 / 3 = 546.66666666667 (the remainder is 2, so 3 is not a divisor of 1640)
  • ...
  • 1640 / 39 = 42.051282051282 (the remainder is 2, so 39 is not a divisor of 1640)
  • 1640 / 40 = 41 (the remainder is 0, so 40 and 41 are divisors of 1640)