This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

PrimeQ

PrimeQ[expr]
yields True if expr is a prime number, and yields False otherwise.
  • PrimeQ[m+In] automatically works over the Gaussian integers.
  • Simplify[exprPrimes] can be used to try to determine whether a symbolic expression is mathematically a prime.
Test whether a number is prime:
Test whether a number is prime:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
PrimeQ threads itself element-wise over lists:
Test for primality over the Gaussian integers:
Only some numbers of the form are prime:
Highlight numbers that are prime:
The distribution of Gaussian primes:
New in 1 | Last modified in 5