CompositeQ
✖
CompositeQ
Details and Options

- CompositeQ is typically used to test whether an integer is a composite number.
- A composite number is a positive number that is the product of two integers other than 1.
- CompositeQ[n] returns False unless n is manifestly a composite number.
- For negative integer n, CompositeQ[n] is effectively equivalent to CompositeQ[-n].
- With the setting GaussianIntegers->True, CompositeQ determines whether a number is a composite number over Gaussian integers.
- CompositeQ[m+In] automatically works over Gaussian integers.

Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (4)Survey of the scope of standard use cases
CompositeQ works over integers:

https://wolfram.com/xid/0bdo3ycm7-mv5gft


https://wolfram.com/xid/0bdo3ycm7-srsb6y


https://wolfram.com/xid/0bdo3ycm7-nqms7k


https://wolfram.com/xid/0bdo3ycm7-845fn4

CompositeQ threads over lists:

https://wolfram.com/xid/0bdo3ycm7-crn

Options (1)Common values & functionality for each option
Applications (9)Sample problems that can be solved with this function
Basic Applications (3)

https://wolfram.com/xid/0bdo3ycm7-bfkjsd

Generate the composite number:

https://wolfram.com/xid/0bdo3ycm7-ct38cw

https://wolfram.com/xid/0bdo3ycm7-ljas3i


https://wolfram.com/xid/0bdo3ycm7-gfuszz

Generate random composite numbers:

https://wolfram.com/xid/0bdo3ycm7-wq2i48

https://wolfram.com/xid/0bdo3ycm7-ibhzx


https://wolfram.com/xid/0bdo3ycm7-ncv8w

The distribution of Gaussian composite numbers:

https://wolfram.com/xid/0bdo3ycm7-b620o8

Number Theory (6)
Recognize Sierpiński numbers k where is always composite:

https://wolfram.com/xid/0bdo3ycm7-uvt145

Recognize powerful numbers n whose prime factors are all repeated:

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

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

All perfect powers are powerful numbers:

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

Recognize base b pseudoprimes, composite numbers n such that :

https://wolfram.com/xid/0bdo3ycm7-73ghej
Find all base pseudoprimes below
:

https://wolfram.com/xid/0bdo3ycm7-ddotbl

Find all base pseudoprimes below
:

https://wolfram.com/xid/0bdo3ycm7-v2utbo

Find large composite numbers of the form :

https://wolfram.com/xid/0bdo3ycm7-c3ghq8

The distribution of composite numbers over integers:

https://wolfram.com/xid/0bdo3ycm7-hi0e4n

https://wolfram.com/xid/0bdo3ycm7-iul1cx

https://wolfram.com/xid/0bdo3ycm7-d4lpp

The distribution of composite numbers over the Gaussian integers:

https://wolfram.com/xid/0bdo3ycm7-9om2p7

https://wolfram.com/xid/0bdo3ycm7-1ullvw

https://wolfram.com/xid/0bdo3ycm7-jrlfrw

Properties & Relations (6)Properties of the function, and connections to other functions
Primes represents the domain of all prime numbers:

https://wolfram.com/xid/0bdo3ycm7-d89n7a

PrimeQ gives False for all composite numbers:

https://wolfram.com/xid/0bdo3ycm7-cocnkk


https://wolfram.com/xid/0bdo3ycm7-dz14y

CompositeQ gives False for all primes:

https://wolfram.com/xid/0bdo3ycm7-4sc00


https://wolfram.com/xid/0bdo3ycm7-jf1u0m

Composite numbers cannot be a MersennePrimeExponent:

https://wolfram.com/xid/0bdo3ycm7-blul38


https://wolfram.com/xid/0bdo3ycm7-c5un5t

Composite numbers have at least two prime factors including multiplicities:

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


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

Composite numbers that are the power of a prime number have exactly
divisors:

https://wolfram.com/xid/0bdo3ycm7-e8dstd


https://wolfram.com/xid/0bdo3ycm7-fryb42

Neat Examples (2)Surprising or curious use cases
Plot composite numbers that are the sum of three squares:

https://wolfram.com/xid/0bdo3ycm7-h7zwj2

Plot the Ulam spiral where numbers are colored based on their compositeness:

https://wolfram.com/xid/0bdo3ycm7-e8n2ht

https://wolfram.com/xid/0bdo3ycm7-qhm0kv

Wolfram Research (2014), CompositeQ, Wolfram Language function, https://reference.wolfram.com/language/ref/CompositeQ.html.
Text
Wolfram Research (2014), CompositeQ, Wolfram Language function, https://reference.wolfram.com/language/ref/CompositeQ.html.
Wolfram Research (2014), CompositeQ, Wolfram Language function, https://reference.wolfram.com/language/ref/CompositeQ.html.
CMS
Wolfram Language. 2014. "CompositeQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CompositeQ.html.
Wolfram Language. 2014. "CompositeQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CompositeQ.html.
APA
Wolfram Language. (2014). CompositeQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CompositeQ.html
Wolfram Language. (2014). CompositeQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CompositeQ.html
BibTeX
@misc{reference.wolfram_2025_compositeq, author="Wolfram Research", title="{CompositeQ}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/CompositeQ.html}", note=[Accessed: 02-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_compositeq, organization={Wolfram Research}, title={CompositeQ}, year={2014}, url={https://reference.wolfram.com/language/ref/CompositeQ.html}, note=[Accessed: 02-May-2025
]}