Navigation

Operators and Keywords

Function List:

C++ API

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

Return the prime factorization of q.

The prime factorization is defined as prod (pf) == q where every element of pf is a prime number. If q == 1, return 1.

With two output arguments, return the unique prime factors pf and their multiplicities. That is, prod (pf .^ n) == q.

Implementation Note: The input q must be less than flintmax (9.0072e+15) in order to factor correctly.

See also: gcd, lcm, isprime, primes.

Package: octave