What are the divisors of 1338?

1, 2, 3, 6, 223, 446, 669, 1338

4 even divisors

2, 6, 446, 1338

4 odd divisors

1, 3, 223, 669

How to compute the divisors of 1338?

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

  • 1338 / 1 = 1338 (the remainder is 0, so 1 is a divisor of 1338)
  • 1338 / 2 = 669 (the remainder is 0, so 2 is a divisor of 1338)
  • 1338 / 3 = 446 (the remainder is 0, so 3 is a divisor of 1338)
  • ...
  • 1338 / 1337 = 1.0007479431563 (the remainder is 1, so 1337 is not a divisor of 1338)
  • 1338 / 1338 = 1 (the remainder is 0, so 1338 is a divisor of 1338)

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 1338 (i.e. 36.578682316344). 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 )

  • 1338 / 1 = 1338 (the remainder is 0, so 1 and 1338 are divisors of 1338)
  • 1338 / 2 = 669 (the remainder is 0, so 2 and 669 are divisors of 1338)
  • 1338 / 3 = 446 (the remainder is 0, so 3 and 446 are divisors of 1338)
  • ...
  • 1338 / 35 = 38.228571428571 (the remainder is 8, so 35 is not a divisor of 1338)
  • 1338 / 36 = 37.166666666667 (the remainder is 6, so 36 is not a divisor of 1338)