What are the divisors of 4158?

1, 2, 3, 6, 7, 9, 11, 14, 18, 21, 22, 27, 33, 42, 54, 63, 66, 77, 99, 126, 154, 189, 198, 231, 297, 378, 462, 594, 693, 1386, 2079, 4158

16 even divisors

2, 6, 14, 18, 22, 42, 54, 66, 126, 154, 198, 378, 462, 594, 1386, 4158

16 odd divisors

1, 3, 7, 9, 11, 21, 27, 33, 63, 77, 99, 189, 231, 297, 693, 2079

How to compute the divisors of 4158?

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

  • 4158 / 1 = 4158 (the remainder is 0, so 1 is a divisor of 4158)
  • 4158 / 2 = 2079 (the remainder is 0, so 2 is a divisor of 4158)
  • 4158 / 3 = 1386 (the remainder is 0, so 3 is a divisor of 4158)
  • ...
  • 4158 / 4157 = 1.0002405580948 (the remainder is 1, so 4157 is not a divisor of 4158)
  • 4158 / 4158 = 1 (the remainder is 0, so 4158 is a divisor of 4158)

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 4158 (i.e. 64.482555780614). 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 )

  • 4158 / 1 = 4158 (the remainder is 0, so 1 and 4158 are divisors of 4158)
  • 4158 / 2 = 2079 (the remainder is 0, so 2 and 2079 are divisors of 4158)
  • 4158 / 3 = 1386 (the remainder is 0, so 3 and 1386 are divisors of 4158)
  • ...
  • 4158 / 63 = 66 (the remainder is 0, so 63 and 66 are divisors of 4158)
  • 4158 / 64 = 64.96875 (the remainder is 62, so 64 is not a divisor of 4158)