gives a list of the prime factors of the integer n, together with their exponents.
FactorInteger[n,k]
does partial factorization, pulling out at most k distinct factors.
FactorInteger
gives a list of the prime factors of the integer n, together with their exponents.
FactorInteger[n,k]
does partial factorization, pulling out at most k distinct factors.
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 all close allBasic Examples (2)
Scope (6)
FactorInteger works over integers:
FactorInteger[36]FactorInteger[3 / 8]FactorInteger[9 + 12I]FactorInteger[36, GaussianIntegers -> True]FactorInteger[20!, 4]FactorInteger[10 ^ 100 + 3, Automatic]FactorInteger[10 ^ 50 + 3]FactorInteger threads over lists:
FactorInteger[{11, 101, 1001}]Options (1)
Applications (12)
Basic Applications (5)
Every positive integer can be represented as a product of prime factors:
FactorInteger[60]FactorInteger[-60]Plot the number of distinct prime factors of numbers up to
:
ListPlot[Table[Length[FactorInteger[n]], {n, 100}]]Compare with the number of distinct prime factors over the Gaussian integers:
ListPlot[Table[Length[FactorInteger[n, GaussianIntegers -> True]], {n, 100}]]Display as an explicit product of factors:
FactorInteger[20!]CenterDot@@(Superscript@@@%)Use FactorInteger to test for prime powers:
MatchQ[FactorInteger[2401], {{_Integer, _Integer}}]PrimePowerQ[2401]Use FactorInteger to find all prime divisors of a number:
Part[FactorInteger[2434500], All, 1]Select[Divisors[2434500], PrimeQ]Number Theory (7)
Use FactorInteger to compute the number of divisors of the number:
Times@@(FactorInteger[6!][[All, -1]] + 1)Length[Divisors[6!]]Use FactorInteger to recognize powerful numbers, numbers whose prime factors are all repeated:
powQ[n_] := AllTrue[Part[FactorInteger[n], All, 2], # > 1&];powQ[324]powQ[75]Find factorizations of numbers of the form
:
Table[FactorInteger[2 ^ 2 ^ n + 1], {n, 7}]//ColumnFind all natural numbers up to 100 that are primes or prime powers:
Select[Range[100], Length[FactorInteger[#]] == 1&]The highest power of a prime in numbers up to 100:
Table[Max[Last /@ FactorInteger[n]], {n, 2, 100}]Find primes that appear in prime factorization of
only to the first power:
FactorInteger[20!]Cases[%, {p_, 1} -> p]Use FactorInteger to compute the square-free part of a number:
squareFreePart[n_] := Times@@Cases[FactorInteger[n], {x_, _} -> x];squareFreePart[18]ListPlot[Table[squareFreePart[a], {a, 1, 1000}]]Properties & Relations (9)
The prime factorization of a prime number is itself:
PrimeQ[11]FactorInteger[11]PrimePowerQ[125]FactorInteger[125]Composite numbers have at least two prime factors including multiplicities:
CompositeQ[60]FactorInteger[60]Compute the original number from a factorization:
FactorInteger[30]Times@@Cases[FactorInteger[30], {a_, b_} -> a ^ b ]Exponents in the prime factorization of a square-free number are all
:
SquareFreeQ[210]FactorInteger[210]Divisors gives the list of divisors including prime divisors:
Select[Divisors[20], PrimeQ]FactorInteger[20]PrimeNu gives the number of distinct prime factors:
Length[FactorInteger[10!]]PrimeNu[10!]PrimeOmega gives the number of prime factors counting multiplicities:
Total[FactorInteger[48][[All, -1]]]PrimeOmega[48]Coprime numbers have no prime factors in common:
CoprimeQ[20, 39]FactorInteger[20]FactorInteger[39]If the prime factorization of n is given by
, then the number of divisors of n is
:
Times@@(FactorInteger[5!][[All, -1]] + 1)Length[Divisors[5!]]Possible Issues (2)
Timings can increase rapidly and unpredictably with the size of the input:
Table[Timing[FactorInteger[2 ^ n - 1];n], {n, 50, 300, 50}]FactorInteger at zero:
FactorInteger[0]History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2003 (5.0) ▪ 2007 (6.0)
Text
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.
APA
Wolfram Language. (1988). FactorInteger. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FactorInteger.html
BibTeX
@misc{reference.wolfram_2026_factorinteger, author="Wolfram Research", title="{FactorInteger}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/FactorInteger.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_factorinteger, organization={Wolfram Research}, title={FactorInteger}, year={2007}, url={https://reference.wolfram.com/language/ref/FactorInteger.html}, note=[Accessed: 13-June-2026]}