What are the divisors of 3162?

1, 2, 3, 6, 17, 31, 34, 51, 62, 93, 102, 186, 527, 1054, 1581, 3162

8 even divisors

2, 6, 34, 62, 102, 186, 1054, 3162

8 odd divisors

1, 3, 17, 31, 51, 93, 527, 1581

How to compute the divisors of 3162?

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

  • 3162 / 1 = 3162 (the remainder is 0, so 1 is a divisor of 3162)
  • 3162 / 2 = 1581 (the remainder is 0, so 2 is a divisor of 3162)
  • 3162 / 3 = 1054 (the remainder is 0, so 3 is a divisor of 3162)
  • ...
  • 3162 / 3161 = 1.0003163555837 (the remainder is 1, so 3161 is not a divisor of 3162)
  • 3162 / 3162 = 1 (the remainder is 0, so 3162 is a divisor of 3162)

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 3162 (i.e. 56.231663678038). 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 )

  • 3162 / 1 = 3162 (the remainder is 0, so 1 and 3162 are divisors of 3162)
  • 3162 / 2 = 1581 (the remainder is 0, so 2 and 1581 are divisors of 3162)
  • 3162 / 3 = 1054 (the remainder is 0, so 3 and 1054 are divisors of 3162)
  • ...
  • 3162 / 55 = 57.490909090909 (the remainder is 27, so 55 is not a divisor of 3162)
  • 3162 / 56 = 56.464285714286 (the remainder is 26, so 56 is not a divisor of 3162)