What are the divisors of 4018?

1, 2, 7, 14, 41, 49, 82, 98, 287, 574, 2009, 4018

6 even divisors

2, 14, 82, 98, 574, 4018

6 odd divisors

1, 7, 41, 49, 287, 2009

How to compute the divisors of 4018?

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

  • 4018 / 1 = 4018 (the remainder is 0, so 1 is a divisor of 4018)
  • 4018 / 2 = 2009 (the remainder is 0, so 2 is a divisor of 4018)
  • 4018 / 3 = 1339.3333333333 (the remainder is 1, so 3 is not a divisor of 4018)
  • ...
  • 4018 / 4017 = 1.0002489419965 (the remainder is 1, so 4017 is not a divisor of 4018)
  • 4018 / 4018 = 1 (the remainder is 0, so 4018 is a divisor of 4018)

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 4018 (i.e. 63.387695966962). 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 )

  • 4018 / 1 = 4018 (the remainder is 0, so 1 and 4018 are divisors of 4018)
  • 4018 / 2 = 2009 (the remainder is 0, so 2 and 2009 are divisors of 4018)
  • 4018 / 3 = 1339.3333333333 (the remainder is 1, so 3 is not a divisor of 4018)
  • ...
  • 4018 / 62 = 64.806451612903 (the remainder is 50, so 62 is not a divisor of 4018)
  • 4018 / 63 = 63.777777777778 (the remainder is 49, so 63 is not a divisor of 4018)