Skip to content

factor

specfun · scripts/specfun/factor.m

: p = factor (q)
: [p, n] = factor (q)

Prime factorization of the non-negative integer scalar q.

With one output, p is a row vector holding all prime factors of q in ascending order, repeated according to multiplicity, so that prod (p) == q. With two outputs, p holds the distinct primes and n (class double) their multiplicities, so that prod (p .^ n) == q.

The class of p is the class of q. The factorization is exact over the whole range of uint64; factor (0) and factor (1) return the argument itself.