What are the divisors of 15?

1, 3, 5, 15

4 odd divisors

1, 3, 5, 15

How to compute the divisors of 15?

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

  • 15 / 1 = 15 (the remainder is 0, so 1 is a divisor of 15)
  • 15 / 2 = 7.5 (the remainder is 1, so 2 is not a divisor of 15)
  • 15 / 3 = 5 (the remainder is 0, so 3 is a divisor of 15)
  • ...
  • 15 / 4 = 3.75 (the remainder is 3, so 4 is not a divisor of 15)
  • 15 / 5 = 3 (the remainder is 0, so 5 is a divisor of 15)
  • 15 / 6 = 2.5 (the remainder is 3, so 6 is not a divisor of 15)
  • 15 / 7 = 2.1428571428571 (the remainder is 1, so 7 is not a divisor of 15)
  • 15 / 8 = 1.875 (the remainder is 7, so 8 is not a divisor of 15)
  • 15 / 9 = 1.6666666666667 (the remainder is 6, so 9 is not a divisor of 15)
  • 15 / 10 = 1.5 (the remainder is 5, so 10 is not a divisor of 15)
  • 15 / 11 = 1.3636363636364 (the remainder is 4, so 11 is not a divisor of 15)
  • 15 / 12 = 1.25 (the remainder is 3, so 12 is not a divisor of 15)
  • 15 / 13 = 1.1538461538462 (the remainder is 2, so 13 is not a divisor of 15)
  • 15 / 14 = 1.0714285714286 (the remainder is 1, so 14 is not a divisor of 15)
  • 15 / 15 = 1 (the remainder is 0, so 15 is a divisor of 15)

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 15 (i.e. 3.8729833462074). 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 )

  • 15 / 1 = 15 (the remainder is 0, so 1 and 15 are divisors of 15)
  • 15 / 2 = 7.5 (the remainder is 1, so 2 is not a divisor of 15)
  • 15 / 3 = 5 (the remainder is 0, so 3 and 5 are divisors of 15)