Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Tests  /
PrimeQ

  • PrimeQ[ expr ] yields True if expr is a prime number, and yields False otherwise.
  • PrimeQ[1] gives False.
  • PrimeQ[- n ], where n is prime, gives True.
  • PrimeQ[ n , GaussianIntegers->True] determines whether n is a Gaussian prime.
  • See the Mathematica book: Section 2.3.5, Section 3.1.1Section 3.2.4.
  • See also Implementation NotesA.9.44.7MainBookLinkOldButtonDataA.9.44.7.
  • See also: FactorInteger.
  • Related package: NumberTheory`PrimeQ`.

    Further Examples

    Not all numbers of the form are prime.

    In[1]:=

    Out[1]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.