# gcd 0 0 = 0

Marc van Dongen dongen@cs.ucc.ie
Sun, 16 Dec 2001 13:35:59 +0000

```Marc van Dongen (dongen@cs.ucc.ie) wrote:

:   An integer \$a\$ divides integer \$b\$ if there exists an integer
:   \$c\$ such that \$a c= b\$.

[snip]

:  gcd 0 0 = 0; and
:  gcd 0 0 /= error "Blah"

To make clear why \$0\$ (and not any other non-zero integer) is the
gcd of \$0\$ and \$0\$ I should have added that for the integer case
\$g\$ is called a greatest common divisor (gcd) of \$a\$ and \$b\$ if it
satifies each of the following two properties:

1) \$g\$ divides both \$a\$ and \$b\$;
2) if \$g'\$ is a common divisor of \$a\$ and \$b\$ then \$g'\$ divides \$g\$.

First notice that \$0\$ is a gcd of \$0\$ and \$0\$ because of the following:
*) \$0\$ divides \$0\$ (and divides \$0\$);
*) whenever \$g'\$ is an integer that divides \$0\$ and divides \$0\$
then \$g'\$ divides \$0\$.

Next notice that if \$g\$ is any non-zero integer then \$g\$ cannot be
a gcd of \$0\$ and \$0\$ because \$0\$ (a common divisor of \$0\$ and \$0\$)
does not divide \$g\$.

Finally, observe that this makes \$0\$ the unique gcd of \$0\$ and \$0\$.

: The gcd of two integers is usually defined as a non-negative
: number to make it unique.

Regards,

Marc van Dongen

```