What are the divisors of 798?

1, 2, 3, 6, 7, 14, 19, 21, 38, 42, 57, 114, 133, 266, 399, 798

8 even divisors

2, 6, 14, 38, 42, 114, 266, 798

8 odd divisors

1, 3, 7, 19, 21, 57, 133, 399

How to compute the divisors of 798?

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

  • 798 / 1 = 798 (the remainder is 0, so 1 is a divisor of 798)
  • 798 / 2 = 399 (the remainder is 0, so 2 is a divisor of 798)
  • 798 / 3 = 266 (the remainder is 0, so 3 is a divisor of 798)
  • ...
  • 798 / 797 = 1.0012547051443 (the remainder is 1, so 797 is not a divisor of 798)
  • 798 / 798 = 1 (the remainder is 0, so 798 is a divisor of 798)

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 798 (i.e. 28.248893783651). 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 )

  • 798 / 1 = 798 (the remainder is 0, so 1 and 798 are divisors of 798)
  • 798 / 2 = 399 (the remainder is 0, so 2 and 399 are divisors of 798)
  • 798 / 3 = 266 (the remainder is 0, so 3 and 266 are divisors of 798)
  • ...
  • 798 / 27 = 29.555555555556 (the remainder is 15, so 27 is not a divisor of 798)
  • 798 / 28 = 28.5 (the remainder is 14, so 28 is not a divisor of 798)