HOW IT WORKS
Finding factor pairs & prime factorization
A positive integer d is a factor (or divisor) of n if dividing n by d leaves a remainder of 0.
Symmetric factor pairs up to √n
Whenever d divides n, its partner n ÷ d also divides n. Checking integers from 1 up to ⌊√n⌋ finds every factor pair without scanning all the way to n.
120 = 1×120 = 2×60 = 3×40 = 4×30 = 5×24 = 6×20 = 8×15 = 10×12Prime factorization
By the Fundamental Theorem of Arithmetic, every integer greater than 1 has a unique prime-power decomposition:
120 = 2³ × 3 × 5Counting total factors from exponents
If n = p₁^a₁ × p₂^a₂ × …, the total number of positive factors is (a₁ + 1)(a₂ + 1)…. For 120, (3 + 1)(1 + 1)(1 + 1) = 16.