WOLFRAM

yields True if n is a composite number, and yields False otherwise.

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 all

Basic Examples  (2)Summary of the most common use cases

Test whether a number is composite:

Out[1]=1

The number is not composite:

Out[1]=1

Scope  (4)Survey of the scope of standard use cases

CompositeQ works over integers:

Out[3]=3

Gaussian integers:

Out[1]=1
Out[2]=2

Test for large integers:

Out[1]=1

CompositeQ threads over lists:

Out[1]=1

Options  (1)Common values & functionality for each option

GaussianIntegers  (1)

Test whether is composite over integers:

Out[10]=10

Gaussian integers:

Out[1]=1

Applications  (9)Sample problems that can be solved with this function

Basic Applications  (3)

Highlight composite numbers:

Out[1]=1

Generate the composite number:

Out[2]=2
Out[3]=3

Generate random composite numbers:

Out[5]=5
Out[6]=6

The distribution of Gaussian composite numbers:

Out[1]=1

Number Theory  (6)

Recognize Sierpiński numbers k where is always composite:

Out[2]=2

Recognize powerful numbers n whose prime factors are all repeated:

Out[2]=2

All perfect powers are powerful numbers:

Out[3]=3

Recognize base b pseudoprimes, composite numbers n such that :

Find all base pseudoprimes below :

Out[2]=2

Find all base pseudoprimes below :

Out[3]=3

Find large composite numbers of the form :

Out[1]=1

The distribution of composite numbers over integers:

Plot the distribution:

Out[3]=3

The distribution of composite numbers over the Gaussian integers:

Plot the distribution:

Out[3]=3

Properties & Relations  (6)Properties of the function, and connections to other functions

Primes represents the domain of all prime numbers:

Out[1]=1

PrimeQ gives False for all composite numbers:

Out[4]=4
Out[5]=5

CompositeQ gives False for all primes:

Out[1]=1
Out[2]=2

Composite numbers cannot be a MersennePrimeExponent:

Out[1]=1
Out[2]=2

Composite numbers have at least two prime factors including multiplicities:

Out[1]=1
Out[2]=2

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

Out[1]=1
Out[2]=2

Neat Examples  (2)Surprising or curious use cases

Plot composite numbers that are the sum of three squares:

Out[1]=1

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

Out[2]=2
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.

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 ]}

@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 ]}

@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 ]}