FactorInteger
✖
FactorInteger
gives a list of the prime factors of the integer n, together with their exponents.
Details and Options

- FactorInteger is also known as prime factorization.
- For a positive number n=p1k1⋯ pmkm with pi primes, FactorInteger[n] gives a list {{p1,k1},…,{pm,km}}.
- For negative numbers, the unit {-1,1} is included in the list of factors.
- FactorInteger also works on rational numbers. The prime factors of the denominator are given with negative exponents.
- FactorInteger[n,GaussianIntegers->True] factors over Gaussian integers.
- FactorInteger[m+I n] automatically works over Gaussian integers.
- When necessary, a unit of the form {-1,1}, {I,1} or {-I,1} is included in the list of factors.
- The last element in the list FactorInteger[n,k] gives what is left after the partial factorization.
- FactorInteger[n,Automatic] pulls out only factors that are easy to find.
- FactorInteger uses PrimeQ to determine whether factors are prime.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (6)Survey of the scope of standard use cases
FactorInteger works over integers:

https://wolfram.com/xid/0enx9tara-h7skky


https://wolfram.com/xid/0enx9tara-gvzk29


https://wolfram.com/xid/0enx9tara-bv9dzr


https://wolfram.com/xid/0enx9tara-bp03jc


https://wolfram.com/xid/0enx9tara-e5bo1e


https://wolfram.com/xid/0enx9tara-5yquql


https://wolfram.com/xid/0enx9tara-dco2wk

FactorInteger threads over lists:

https://wolfram.com/xid/0enx9tara-0khk1r

Options (1)Common values & functionality for each option
Applications (12)Sample problems that can be solved with this function
Basic Applications (5)
Every positive integer can be represented as a product of prime factors:

https://wolfram.com/xid/0enx9tara-lgbdq


https://wolfram.com/xid/0enx9tara-0oy1zc

Plot the number of distinct prime factors of numbers up to :

https://wolfram.com/xid/0enx9tara-gdv

Compare with the number of distinct prime factors over the Gaussian integers:

https://wolfram.com/xid/0enx9tara-kcb

Display as an explicit product of factors:

https://wolfram.com/xid/0enx9tara-v9i


https://wolfram.com/xid/0enx9tara-bw2

Use FactorInteger to test for prime powers:

https://wolfram.com/xid/0enx9tara-efcup7


https://wolfram.com/xid/0enx9tara-uc5qr5

Use FactorInteger to find all prime divisors of a number:

https://wolfram.com/xid/0enx9tara-pefmwt


https://wolfram.com/xid/0enx9tara-ona38t

Number Theory (7)
Use FactorInteger to compute the number of divisors of the number:

https://wolfram.com/xid/0enx9tara-dny2q5


https://wolfram.com/xid/0enx9tara-jdh9sy

Use FactorInteger to recognize powerful numbers, numbers whose prime factors are all repeated:

https://wolfram.com/xid/0enx9tara-3x7iu

https://wolfram.com/xid/0enx9tara-bps1v3


https://wolfram.com/xid/0enx9tara-g4cjq

Find factorizations of numbers of the form :

https://wolfram.com/xid/0enx9tara-c4k

Find all natural numbers up to 100 that are primes or prime powers:

https://wolfram.com/xid/0enx9tara-vdr

The highest power of a prime in numbers up to 100:

https://wolfram.com/xid/0enx9tara-re0

Find primes that appear in prime factorization of only to the first power:

https://wolfram.com/xid/0enx9tara-wpc


https://wolfram.com/xid/0enx9tara-dd3

Use FactorInteger to compute the square-free part of a number:

https://wolfram.com/xid/0enx9tara-kzeujz

https://wolfram.com/xid/0enx9tara-52qujd


https://wolfram.com/xid/0enx9tara-76rbjv

Properties & Relations (9)Properties of the function, and connections to other functions
The prime factorization of a prime number is itself:

https://wolfram.com/xid/0enx9tara-konju4


https://wolfram.com/xid/0enx9tara-dab0xs


https://wolfram.com/xid/0enx9tara-hbn4a7


https://wolfram.com/xid/0enx9tara-bog1xe

Composite numbers have at least two prime factors including multiplicities:

https://wolfram.com/xid/0enx9tara-z74y0b


https://wolfram.com/xid/0enx9tara-krrkpj

Compute the original number from a factorization:

https://wolfram.com/xid/0enx9tara-qyepwb


https://wolfram.com/xid/0enx9tara-ka8wbr

Exponents in the prime factorization of a square-free number are all :

https://wolfram.com/xid/0enx9tara-c5x9z


https://wolfram.com/xid/0enx9tara-m1yhtl

Divisors gives the list of divisors including prime divisors:

https://wolfram.com/xid/0enx9tara-4db6ss


https://wolfram.com/xid/0enx9tara-je44me

PrimeNu gives the number of distinct prime factors:

https://wolfram.com/xid/0enx9tara-9fi76v


https://wolfram.com/xid/0enx9tara-l073yk

PrimeOmega gives the number of prime factors counting multiplicities:

https://wolfram.com/xid/0enx9tara-dosvv2


https://wolfram.com/xid/0enx9tara-2298n

Coprime numbers have no prime factors in common:

https://wolfram.com/xid/0enx9tara-mtarak


https://wolfram.com/xid/0enx9tara-spxt2r


https://wolfram.com/xid/0enx9tara-vok8bj

If the prime factorization of n is given by , then the number of divisors of n is
:

https://wolfram.com/xid/0enx9tara-0hqi2


https://wolfram.com/xid/0enx9tara-6qfue

Possible Issues (2)Common pitfalls and unexpected behavior
Timings can increase rapidly and unpredictably with the size of the input:

https://wolfram.com/xid/0enx9tara-le1

FactorInteger at zero:

https://wolfram.com/xid/0enx9tara-hkd5ly

Wolfram Research (1988), FactorInteger, Wolfram Language function, https://reference.wolfram.com/language/ref/FactorInteger.html (updated 2007).
Text
Wolfram Research (1988), FactorInteger, Wolfram Language function, https://reference.wolfram.com/language/ref/FactorInteger.html (updated 2007).
Wolfram Research (1988), FactorInteger, Wolfram Language function, https://reference.wolfram.com/language/ref/FactorInteger.html (updated 2007).
CMS
Wolfram Language. 1988. "FactorInteger." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/FactorInteger.html.
Wolfram Language. 1988. "FactorInteger." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/FactorInteger.html.
APA
Wolfram Language. (1988). FactorInteger. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FactorInteger.html
Wolfram Language. (1988). FactorInteger. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FactorInteger.html
BibTeX
@misc{reference.wolfram_2025_factorinteger, author="Wolfram Research", title="{FactorInteger}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/FactorInteger.html}", note=[Accessed: 19-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_factorinteger, organization={Wolfram Research}, title={FactorInteger}, year={2007}, url={https://reference.wolfram.com/language/ref/FactorInteger.html}, note=[Accessed: 19-June-2025
]}