Skip to content

IsCoprime ​

Tests whether the arguments are pairwise relatively prime.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageCoprimeQ✓
IsCoprime(a, b, …)true when every pair of arguments is coprime
Typed signatures
TypePackageApplies
(number+) -> booleannumber-theoryalways

Domain: Number theory

Details
  • Pairwise, not collectively: gcd⁡\gcd of the whole set being 1 is not enough — every pair must itself be coprime.
  • Extends to Gaussian integers, over the same GCD this widens.
  • Wolfram's CoprimeQ.

Examples

Basic #
live ↗
InIsCoprime(4,9)\mathrm{IsCoprime}(4, 9)OutTrue\mathrm{True}

Both are divisible by 3

live ↗
InIsCoprime(6,9)\mathrm{IsCoprime}(6, 9)OutFalse\mathrm{False}

Several arguments: every pair must be coprime

live ↗
InIsCoprime(2,3,5)\mathrm{IsCoprime}(2, 3, 5)OutTrue\mathrm{True}

No shared factor, so coprime

live ↗
InIsCoprime(8,11)\mathrm{IsCoprime}(8, 11)OutTrue\mathrm{True}

Both even, so not coprime

live ↗
InIsCoprime(2,4)\mathrm{IsCoprime}(2, 4)OutFalse\mathrm{False}
Scope #

Gaussian integers: 2+i2+i and 2−i2-i are non-associate primes

live ↗
InIsCoprime(2+i,2−i)\mathrm{IsCoprime}(2+i, 2-i)OutTrue\mathrm{True}

Listable

live ↗
InIsCoprime(3,[4,6])\mathrm{IsCoprime}(3, \bigl\lbrack4, 6\bigr\rbrack)Out[True,False]\bigl\lbrack\mathrm{True}, \mathrm{False}\bigr\rbrack

Several arguments must be pairwise coprime; signs are ignored

live ↗
InIsCoprime(2,3,−5,7)\mathrm{IsCoprime}(2, 3, -5, 7)OutTrue\mathrm{True}

Gaussian integers: both divisible by 1+i1+i up to a unit

live ↗
InIsCoprime(5+i,1−i)\mathrm{IsCoprime}(5+i, 1-i)OutFalse\mathrm{False}

Large integers handled exactly; these share a factor

live ↗
InIsCoprime(2100−1,3100−1)\mathrm{IsCoprime}(2^{100}-1, 3^{100}-1)OutFalse\mathrm{False}

Threads over a list against 6

live ↗
InIsCoprime([1,2,3,4,5],6)\mathrm{IsCoprime}(\bigl\lbrack1, 2, 3, 4, 5\bigr\rbrack, 6)Out[True,False,False,False,True]\bigl\lbrack\mathrm{True}, \mathrm{False}, \mathrm{False}, \mathrm{False}, \mathrm{True}\bigr\rbrack

Distinct primes are coprime

live ↗
InIsCoprime(2,3)\mathrm{IsCoprime}(2, 3)OutTrue\mathrm{True}
Applications #

Consecutive integers are always coprime

live ↗
InIsCoprime(5,6)\mathrm{IsCoprime}(5, 6)OutTrue\mathrm{True}

Two distinct odd primes share no factor

live ↗
InIsCoprime(5,3)\mathrm{IsCoprime}(5, 3)OutTrue\mathrm{True}
Properties #

232^3 and 323^2: coprime powers of distinct primes

live ↗
InIsCoprime(8,9)\mathrm{IsCoprime}(8, 9)OutTrue\mathrm{True}

A prime is coprime to anything it does not divide

live ↗
InIsCoprime(6,11)\mathrm{IsCoprime}(6, 11)OutTrue\mathrm{True}

No shared factor between 5 and 22⋅32^2\cdot 3

live ↗
InIsCoprime(5,12)\mathrm{IsCoprime}(5, 12)OutTrue\mathrm{True}

Symbolic arguments are taken as not provably coprime

live ↗
InIsCoprime(a,b)\mathrm{IsCoprime}(a, b)OutFalse\mathrm{False}

Distinct primes are pairwise coprime

live ↗
InIsCoprime(NthPrime(10),NthPrime(15),NthPrime(20),NthPrime(25))\mathrm{IsCoprime}(\mathrm{NthPrime}(10), \mathrm{NthPrime}(15), \mathrm{NthPrime}(20), \mathrm{NthPrime}(25))OutTrue\mathrm{True}

No shared factor between 7 and 2⋅52\cdot 5

live ↗
InIsCoprime(7,10)\mathrm{IsCoprime}(7, 10)OutTrue\mathrm{True}
Possible issues #

Pairwise, not collectively: gcd⁡(6,10,15)=1\gcd(6,10,15)=1 yet no pair is coprime

live ↗
InIsCoprime(6,10,15)\mathrm{IsCoprime}(6, 10, 15)OutFalse\mathrm{False}
About
Examples21
Checked againstWolfram Language 21 agree
CrosswalkWolfram Language

See also: GCD, IsPrime