What are the divisors of 378?

1, 2, 3, 6, 7, 9, 14, 18, 21, 27, 42, 54, 63, 126, 189, 378

8 even divisors

2, 6, 14, 18, 42, 54, 126, 378

8 odd divisors

1, 3, 7, 9, 21, 27, 63, 189

How to compute the divisors of 378?

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

  • 378 / 1 = 378 (the remainder is 0, so 1 is a divisor of 378)
  • 378 / 2 = 189 (the remainder is 0, so 2 is a divisor of 378)
  • 378 / 3 = 126 (the remainder is 0, so 3 is a divisor of 378)
  • ...
  • 378 / 377 = 1.0026525198939 (the remainder is 1, so 377 is not a divisor of 378)
  • 378 / 378 = 1 (the remainder is 0, so 378 is a divisor of 378)

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 378 (i.e. 19.442222095224). 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 )

  • 378 / 1 = 378 (the remainder is 0, so 1 and 378 are divisors of 378)
  • 378 / 2 = 189 (the remainder is 0, so 2 and 189 are divisors of 378)
  • 378 / 3 = 126 (the remainder is 0, so 3 and 126 are divisors of 378)
  • ...
  • 378 / 18 = 21 (the remainder is 0, so 18 and 21 are divisors of 378)
  • 378 / 19 = 19.894736842105 (the remainder is 17, so 19 is not a divisor of 378)