Home

gcd0

Gcd0 is a term used in some mathematical and computational contexts to denote a conventionally extended greatest common divisor function that assigns a value for all integer pairs, including the case (0,0). It behaves like the ordinary greatest common divisor for nonzero pairs and provides a definite value when one or both arguments are zero.

Definition. Gcd0 maps Z × Z to Z and is defined by: gcd0(a,b) = gcd(|a|,|b|) for any pair

Properties. Gcd0 is symmetric: gcd0(a,b) = gcd0(b,a). It agrees with the usual positive gcd for all nonzero

Relation to standard gcd and lcm. For any pair not both zero, gcd0(a,b) equals the conventional gcd

Examples. gcd0(18,24) = 6; gcd0(0,12) = 12; gcd0(0,0) = 0. In many programming libraries, the implemented gcd function matches

(a,b)
not
equal
to
(0,0);
gcd0(0,0)
is
defined
to
be
0.
Consequently,
gcd0(a,0)
=
|a|
and
gcd0(0,b)
=
|b|.
This
makes
gcd0
a
total
function
on
Z
×
Z,
avoiding
undefined
cases
at
(0,0).
pairs.
The
value
is
nonnegative,
and
gcd0(a,b)
=
gcd0(|a|,|b|).
It
supports
the
same
basic
gcd
identities
as
the
standard
gcd,
including
its
use
in
the
extended
gcd
framework,
and
it
extends
naturally
to
multiple
arguments
via
gcd0(a,b,c)
=
gcd0(gcd0(a,b),
c).
with
positive
output.
If
one
defines
lcm
by
lcm(a,b)
=
|a
b|
/
gcd(a,b)
when
gcd(a,b)
≠
0,
gcd0
definitions
preserve
this
relationship
where
appropriate.
The
special
case
gcd0(0,0)
=
0
is
a
convention
chosen
to
obtain
a
total
function.
gcd0,
returning
0
for
gcd(0,0).