What are the divisors of 5000?

1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 625, 1000, 1250, 2500, 5000

15 even divisors

2, 4, 8, 10, 20, 40, 50, 100, 200, 250, 500, 1000, 1250, 2500, 5000

5 odd divisors

1, 5, 25, 125, 625

How to compute the divisors of 5000?

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

  • 5000 / 1 = 5000 (the remainder is 0, so 1 is a divisor of 5000)
  • 5000 / 2 = 2500 (the remainder is 0, so 2 is a divisor of 5000)
  • 5000 / 3 = 1666.6666666667 (the remainder is 2, so 3 is not a divisor of 5000)
  • ...
  • 5000 / 4999 = 1.000200040008 (the remainder is 1, so 4999 is not a divisor of 5000)
  • 5000 / 5000 = 1 (the remainder is 0, so 5000 is a divisor of 5000)

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 5000 (i.e. 70.710678118655). 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 )

  • 5000 / 1 = 5000 (the remainder is 0, so 1 and 5000 are divisors of 5000)
  • 5000 / 2 = 2500 (the remainder is 0, so 2 and 2500 are divisors of 5000)
  • 5000 / 3 = 1666.6666666667 (the remainder is 2, so 3 is not a divisor of 5000)
  • ...
  • 5000 / 69 = 72.463768115942 (the remainder is 32, so 69 is not a divisor of 5000)
  • 5000 / 70 = 71.428571428571 (the remainder is 30, so 70 is not a divisor of 5000)