Factors of a Number
Efficiently computes all positive integer factors (divisors) of a number.
getFactors
The getFactors function efficiently computes all positive integer factors (divisors) of a number.
Function Signature
function getFactors(int: Numeric | undefined): number[]Parameters
int(Numeric | undefined): A numeric value or numeric string to find factors for. Can also beundefined.
Return Value
number[]: An array of positive integer factors in ascending order for valid input, or an empty array for invalid inputs (e.g. non-integers, negative numbers, orundefined).
Example Usage
playground.ts
Notes
- Uses the square root method for optimal performance (
O(√n)complexity). - Factors are always returned in ascending order.
Aliases
factorsOfgetDivisors
See Also
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
