Skip to content

divisors

The divisors function returns all positive integer divisors of a number.

Syntax

typescript
divisors(value)

Parameters

NameTypeDescription
valuenumberPositive integer to be analyzed.

Return Value

TypeDescription
number[]Array of all positive divisors of value.

Examples

typescript
divisors(12); // [1, 2, 3, 4, 6, 12]
divisors(7);  // [1, 7]

Notes

  • Throws a TypeError if the value is not a positive integer.
  • Useful for factor analysis, mathematics, and algorithms.

References

Released under the MIT License.