What are the divisors of 4000?

1, 2, 4, 5, 8, 10, 16, 20, 25, 32, 40, 50, 80, 100, 125, 160, 200, 250, 400, 500, 800, 1000, 2000, 4000

20 even divisors

2, 4, 8, 10, 16, 20, 32, 40, 50, 80, 100, 160, 200, 250, 400, 500, 800, 1000, 2000, 4000

4 odd divisors

1, 5, 25, 125

How to compute the divisors of 4000?

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

  • 4000 / 1 = 4000 (the remainder is 0, so 1 is a divisor of 4000)
  • 4000 / 2 = 2000 (the remainder is 0, so 2 is a divisor of 4000)
  • 4000 / 3 = 1333.3333333333 (the remainder is 1, so 3 is not a divisor of 4000)
  • ...
  • 4000 / 3999 = 1.0002500625156 (the remainder is 1, so 3999 is not a divisor of 4000)
  • 4000 / 4000 = 1 (the remainder is 0, so 4000 is a divisor of 4000)

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 4000 (i.e. 63.245553203368). 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 )

  • 4000 / 1 = 4000 (the remainder is 0, so 1 and 4000 are divisors of 4000)
  • 4000 / 2 = 2000 (the remainder is 0, so 2 and 2000 are divisors of 4000)
  • 4000 / 3 = 1333.3333333333 (the remainder is 1, so 3 is not a divisor of 4000)
  • ...
  • 4000 / 62 = 64.516129032258 (the remainder is 32, so 62 is not a divisor of 4000)
  • 4000 / 63 = 63.492063492063 (the remainder is 31, so 63 is not a divisor of 4000)