What are the divisors of 509?

1, 509

2 odd divisors

1, 509

How to compute the divisors of 509?

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

  • 509 / 1 = 509 (the remainder is 0, so 1 is a divisor of 509)
  • 509 / 2 = 254.5 (the remainder is 1, so 2 is not a divisor of 509)
  • 509 / 3 = 169.66666666667 (the remainder is 2, so 3 is not a divisor of 509)
  • ...
  • 509 / 508 = 1.001968503937 (the remainder is 1, so 508 is not a divisor of 509)
  • 509 / 509 = 1 (the remainder is 0, so 509 is a divisor of 509)

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 509 (i.e. 22.561028345357). 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 )

  • 509 / 1 = 509 (the remainder is 0, so 1 and 509 are divisors of 509)
  • 509 / 2 = 254.5 (the remainder is 1, so 2 is not a divisor of 509)
  • 509 / 3 = 169.66666666667 (the remainder is 2, so 3 is not a divisor of 509)
  • ...
  • 509 / 21 = 24.238095238095 (the remainder is 5, so 21 is not a divisor of 509)
  • 509 / 22 = 23.136363636364 (the remainder is 3, so 22 is not a divisor of 509)