Project Nayuki


Calculate divisors (JavaScript)

Program

Divisors:

Description

This JavaScript program lists all the divisors of the given integer. The number must be between 1 and 253.

If the number is very large, the program may hang for a few seconds. This is because the worst-case running time for the number n is O(√n).

The source code is available for viewing.

Examples

  • 6: 1, 2, 3, 6
  • 17: 1, 17 (prime)
  • 25: 1, 5, 25 (perfect square)

More info