

CoprimeQ
Details

- CoprimeQ is typically used to test whether two numbers are relatively prime.
- Integers are relatively prime if their greatest common divisor is 1.
- CoprimeQ[n1,n2] returns False unless n1,n2 are manifestly relatively prime.
- With the setting GaussianIntegers->True, CoprimeQ tests whether Gaussian integers are relatively prime.
- CoprimeQ works over Gaussian integers.

Examples
open all close allBasic Examples (2)
Scope (4)
Applications (8)
Basic Applications (3)
Number Theory (5)
Use CoprimeQ to compute Euler's totient function:
Use CoprimeQ to check for trivial GCDs:
Find the fraction of pairs of the first numbers that are relatively prime:
Compute the modular inverse of coprime numbers:
Use ExtendedGCD:
Properties & Relations (9)
Coprime numbers have a greatest common divisor GCD equal to :
The least common multiple LCM of two coprime numbers is equal to their product:
The number of divisors of a number preserves multiplication for coprime numbers:
Coprime numbers a and b satisfy for some integers x and y:
The numbers and
are the only integers coprime to every integer:
Prime numbers are relatively prime to each other:
EulerPhi gives the count of the positive integers up to n that are relatively prime to n:
See Also
GCD Divisible Mod PrimeQ CompositeQ FactorInteger EulerPhi Prime
Function Repository: CoprimeIntegerList
Tech Notes
Related Guides
History
Text
Wolfram Research (2007), CoprimeQ, Wolfram Language function, https://reference.wolfram.com/language/ref/CoprimeQ.html.
CMS
Wolfram Language. 2007. "CoprimeQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CoprimeQ.html.
APA
Wolfram Language. (2007). CoprimeQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CoprimeQ.html
BibTeX
@misc{reference.wolfram_2025_coprimeq, author="Wolfram Research", title="{CoprimeQ}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/CoprimeQ.html}", note=[Accessed: 09-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_coprimeq, organization={Wolfram Research}, title={CoprimeQ}, year={2007}, url={https://reference.wolfram.com/language/ref/CoprimeQ.html}, note=[Accessed: 09-August-2025]}