= Smallest prime factor
{title2=$\operatorname{spf}(n)$}
= Smallest-factor
{synonym}
= SPF
{c}
{synonym}
For an <integer> $n\ge2$, its <smallest prime factor> $\operatorname{spf}(n)$ is the least <prime divisor> of $n$. If $n$ is prime, it equals $n$; if $n$ is composite, it is at most $\sqrt n$, because otherwise every product of two prime factors would exceed $n$.
For example, $\operatorname{spf}(91)=7$. A sieve can tabulate <smallest prime factors> for all <integers> up to a bound. Repeatedly replacing $n$ by $n/\operatorname{spf}(n)$ then produces its <prime factorization>. The value at one is a sentinel convention in implementations, since one has no prime factor.
Back to article page