Relatively prime integers share no common positive divisor except 1. Using the notation to denote the greatest
common divisor, two integers
and
are relatively prime iff
. Relatively prime integers
are sometimes also called strangers or coprime and
are denoted
.
The plot above plots
and
along the two axes and colors a square black if
and white otherwise (left figure) and simply colored
according to
(right figure).
Two integers can be tested to see if they are relatively prime in the Wolfram Language using CoprimeQ[m, n].
Two distinct primes and
are always relatively prime,
, as are any positive
integer powers of distinct primes
and
,
.
Relative primality is not transitive. For example, and
, but
.
For two independently and uniformly chosen positive integers
and
from
,
the limiting probability as
that they are relatively prime is
|
(1)
|
(OEIS A059956; Cesàro and Sylvester 1883, Lehmer 1900, Sylvester 1909, Nymann 1972; Wells 1986, p. 28; Borwein and
Bailey 2003, p. 139; Havil 2003, pp. 40 and 65; Moree 2005), where is the Riemann
zeta function. This result is related to the fact that the greatest
common divisor of
and
,
, can be interpreted as the number
of lattice points in the plane
which lie on the line segment connecting the vectors
and
(excluding
itself). In fact,
is the natural density
of lattice points with positive
integer coordinates visible from the origin
(Castellanos 1988, pp. 155-156).
Similarly, for three independent positive integers ,
, and
sampled uniformly from
, the limiting probability
as
that their common greatest common divisor
is 1 is
|
(2)
|
(OEIS A088453; Wells 1986, p. 29), where is Apéry's
constant (Wells 1986, p. 29). In general, for
independent positive integers
sampled in this way and a positive integer
with
, the limiting probability
that no common divisor is a
th power
with integer
is
(Cohen 1959, Salamin 1972, Nymann 1975, Schoenfeld
1976, Porubský 1981, Chidambaraswamy and Sitaramachandra Rao 1987, Hafner
et al. 1993).
For Gaussian integers, two elements are relatively prime when all their common divisors are units.
For two independently and uniformly chosen Gaussian
integers
and
of complex modulus at most
, the limiting probability
as
that they are relatively prime is
|
(3)
|
(OEIS A088454), where is Catalan's constant
(Collins and Johnson 1989, Pegg 2003; Finch 2003, p. 601).
Similarly, for two independently and uniformly chosen Eisenstein integers of complex modulus at most , the limiting probability
as
that their only common divisors are units
is
|
(4)
|
(OEIS A088467), where
|
(5)
|
(Finch 2003, p. 601), which can be written analytically as
|
(6)
| |||
|
(7)
|
(OEIS A086724), where is the trigamma function.
The limiting probabilities for pairs of integers and Gaussian integers being relatively prime also equal the natural densities of squarefree elements of the respective rings.