What are the divisors of 5002?

1, 2, 41, 61, 82, 122, 2501, 5002

4 even divisors

2, 82, 122, 5002

4 odd divisors

1, 41, 61, 2501

How to compute the divisors of 5002?

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

  • 5002 / 1 = 5002 (the remainder is 0, so 1 is a divisor of 5002)
  • 5002 / 2 = 2501 (the remainder is 0, so 2 is a divisor of 5002)
  • 5002 / 3 = 1667.3333333333 (the remainder is 1, so 3 is not a divisor of 5002)
  • ...
  • 5002 / 5001 = 1.000199960008 (the remainder is 1, so 5001 is not a divisor of 5002)
  • 5002 / 5002 = 1 (the remainder is 0, so 5002 is a divisor of 5002)

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 5002 (i.e. 70.724818840348). 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 )

  • 5002 / 1 = 5002 (the remainder is 0, so 1 and 5002 are divisors of 5002)
  • 5002 / 2 = 2501 (the remainder is 0, so 2 and 2501 are divisors of 5002)
  • 5002 / 3 = 1667.3333333333 (the remainder is 1, so 3 is not a divisor of 5002)
  • ...
  • 5002 / 69 = 72.492753623188 (the remainder is 34, so 69 is not a divisor of 5002)
  • 5002 / 70 = 71.457142857143 (the remainder is 32, so 70 is not a divisor of 5002)