represents the domain of prime numbers, as in x∈Primes.
Primes
represents the domain of prime numbers, as in x∈Primes.
Details
- x∈Primes evaluates only if x is a numeric quantity.
- Simplify[expr∈Primes] can be used to try to determine whether an expression corresponds to a prime number.
- The domain of primes is taken to be a subset of the domain of integers.
- PrimeQ[expr] returns False unless expr explicitly has head Integer.
- Primes is output in TraditionalForm as
. This typeset form can be input using
pris
.
Examples
open all close allBasic Examples (3)
Scope (4)
Test domain membership of a numeric expression:
Element[107, Primes]Make domain membership assumptions:
FullSimplify[GCD[p, q], Element[p | q, Primes] && p ≠ q]Specify the default domain for Reduce and FindInstance:
Reduce[x ^ 2 + y ^ 2 ≤ 10, {x, y}, Primes]FindInstance[p > 10 ^ 10, p, Primes]TraditionalForm formatting:
Primes//TraditionalFormApplications (2)
Wilson's theorem [more info]:
FullSimplify[Mod[(p - 1)!, p], Element[p, Primes]]p /. FindInstance[Element[p, Primes] && Element[p + 2, Primes], p, 5](And @@ PrimeQ[{#, # + 2}])& /@ %Properties & Relations (3)
Primes is contained in Complexes, Reals, Algebraics, Rationals, and Integers:
Refine[Element[x, #], Element[x, Primes]]& /@ {Complexes, Reals, Algebraics, Rationals, Integers}Simplifications involving prime numbers:
Simplify[p + 1∈Primes, p∈Primes && p > 2]Simplify[Cos[(p + q)π], p∈Primes && q∈Primes && p > 2 && q > 2]Primes represents the set of positive integers that are prime:
Element[#, Primes]& /@ {17, -17}PrimeQ gives True if an integer, positive or negative, is prime:
PrimeQ /@ {17, -17}PrimeQ returns True for explicit numeric primes and False otherwise:
PrimeQ /@ {7, a, (E + 7) ^ 2 / 7 - E ^ 2 / 7 - 2E}Element remains unevaluated when it cannot decide whether an expression is a prime:
Element[#, Primes]& /@ {7, a, (E + 7) ^ 2 / 7 - E ^ 2 / 7 - 2E}Simplify[%]Tech Notes
Related Guides
History
Introduced in 1999 (4.0) | Updated in 2017 (11.2)
Text
Wolfram Research (1999), Primes, Wolfram Language function, https://reference.wolfram.com/language/ref/Primes.html (updated 2017).
CMS
Wolfram Language. 1999. "Primes." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/Primes.html.
APA
Wolfram Language. (1999). Primes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Primes.html
BibTeX
@misc{reference.wolfram_2026_primes, author="Wolfram Research", title="{Primes}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/Primes.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_primes, organization={Wolfram Research}, title={Primes}, year={2017}, url={https://reference.wolfram.com/language/ref/Primes.html}, note=[Accessed: 13-June-2026]}