91
$\begingroup$

What is the greatest common divisor of $0$ and $0$? On the one hand, Wolfram Alpha says that it is $0$; on the other hand, it also claims that $100$ divides $0$, so $100$ should be a greater common divisor of $0$ and $0$ than $0$.

$\endgroup$
4
  • 4
    $\begingroup$ It is typically not defined. $\endgroup$
    – copper.hat
    Sep 16, 2013 at 4:58
  • $\begingroup$ Relevant: en.wikipedia.org/wiki/Partially_ordered_set $\endgroup$
    – anon
    Sep 16, 2013 at 5:23
  • 1
    $\begingroup$ A fancy expression: $\gcd(a, b) = \operatorname{char} \mathbb{Z}/(a, b)$. $\endgroup$
    – Orat
    Dec 20, 2018 at 19:02
  • 1
    $\begingroup$ $\gcd(0,0) = 0\ $ by $\, d\mid 0,0\iff d\mid 0,\,$ see the GCD Universal Property $\ \ $ $\endgroup$ Nov 6, 2019 at 21:12

8 Answers 8

132
$\begingroup$

The word "greatest" in "Greatest Common Divisor" does not refer to being largest in the usual ordering of the natural numbers, but to being largest in the partial order of divisibility on the natural numbers, where we consider $a$ to be larger than $b$ only when $b$ divides evenly into $a$. Most of the time, these two orderings agree whenever the second is defined. However, while, under the usual order, $0$ is the smallest natural number, under the divisibility order, $0$ is the greatest natural number, because every number divides $0$.

Therefore, since every natural number is a common divisor of $0$ and $0$, and $0$ is the greatest (in divisibility) of the natural numbers, $\gcd(0,0)=0$.

$\endgroup$
9
  • 12
    $\begingroup$ Similarly $\gcd(0,n)=n$ for all $n\in\Bbb N$ (including $n=0$). $\endgroup$
    – anon
    Sep 16, 2013 at 5:22
  • 21
    $\begingroup$ Thanks, great answer! How did you figure this out? Where do mathematicians store such commonly agreed on, but not completely obvious definitions? When did people start defining gcd this way, I assume they didn't when Euclidean algorithm was invented 300BC? $\endgroup$ Sep 16, 2013 at 6:55
  • 5
    $\begingroup$ For the most part, the partial order of divisibility coincides with the usual ordering wherever it is defined. So if $\le$ represents the usual ordering and $\vert$ represents the partial order of divisibility, then $x\vert y\Rightarrow x\le y$, except if $y=0$. Moreover, if $x$ is a common divisor of two non-zero natural numbers $a$ and $b$, then $x\le\gcd(a,b)\Rightarrow x\vert\gcd(a,b)$. So in most cases, you can define $\gcd(a,b)$ to be the greatest common divisor of $a$ and $b$, where 'greatest' refers to the usual ordering. That's what Euler did (and left $\gcd(0,0)$ undefined). $\endgroup$ Sep 16, 2013 at 11:55
  • 4
    $\begingroup$ Euclid, I mean.... $\endgroup$ Sep 16, 2013 at 14:50
  • 4
    $\begingroup$ @KonstantinWeitz I wish such an Official Book of All Mathematical Definitions existed. It would end every dispute, because one could simply refer to that book and consult the definition and case closed. But guess what: I asked many mathematicians and none could point out any such book :P I'm starting to believe that they're all making things up :P They seem to be able to pull any definition they please up their butt and claim that "because Mathematics says so, so shut up and calculate" ;q Once I was looking for a definition of an angle, and I found over 9 of them, all of them different :P $\endgroup$ Mar 20, 2017 at 6:26
34
$\begingroup$

I answered this already in a comment at MO: "The best way to think about this is that the "gcd" of two natural numbers is the meet of them in the lattice of natural numbers ordered by divisibility. Note that $0$ is the top element in the divisibility order. The meet of the top element with itself is itself. So $0 = \gcd(0, 0)$ is the answer. 'Greatest' is an unfortunate misnomer in this case."

The book Mathematics Made Difficult has a nice little section on this. It should perhaps better be called "highest common factor" (hcf).

$\endgroup$
4
  • $\begingroup$ You lost the race to William. $\endgroup$
    – dfeuer
    Sep 16, 2013 at 5:05
  • $\begingroup$ we all lost to him :) $\endgroup$
    – DanielY
    Sep 16, 2013 at 5:06
  • 4
    $\begingroup$ @dfeuer Well, I had answered the question already at MO. I wasn't racing. $\endgroup$
    – user43208
    Sep 16, 2013 at 5:06
  • 8
    $\begingroup$ Win or lose, "the meet of [two numbers] in the lattice of natural numbers ordered by divisibility" is a definition of delightful pithiness. $\endgroup$ Sep 16, 2013 at 11:00
12
$\begingroup$

Another way to think about this is ideals. The gcd of two natural numbers $a, b$ is the unique non-negative natural number that generates the ideal $\langle a, b \rangle$. So in this case, $\langle 0 ,0 \rangle$ is just the $0$ ideal so the gcd is $0$.

$\endgroup$
12
$\begingroup$

Simply said - this depends on your definition.

Clearly, if $d=\gcd(a,b)$, you require $d\mid a$, $d\mid b$, i.e., it is a common divisor.

But there are two possibilities how to express that it is greatest common divisor.

One of them is to require $$c\mid a \land c \mid b \Rightarrow c\le d$$ and the other one is $$c\mid a \land c \mid b \Rightarrow c\mid d.$$

Clearly, if you use the first definition, $\gcd(0,0)$ would be the largest integer, so it does not exists. If you use the second one, you get $\gcd(0,0)=0$. (Notice that $0$ is the largest element of the partially ordered set $(\mathbb N,\mid)$.)

As far as I can say, the first definition appears in some text which are "for beginners"; for example here. (It was one of the first results from Google Books when searching for "gcd(0,0)".)

I would say that for students not knowing that $\mid$ is in fact a partial order, the first definition might feel more natural. But once you want to use this in connection with more advanced stuff (for example, g.c.d. as generator of an ideal generated by $a$ and $b$), then the second definition is better.

$\endgroup$
3
  • $\begingroup$ This helped. I still feel a little icky about (ℕ,∣) as a partial order, because 0∣0 feels weird to me, and this whole argument requires that reflexivity. $\endgroup$
    – rampion
    Apr 8, 2015 at 0:46
  • $\begingroup$ What's an ideal, in simple terms? $\endgroup$ Mar 20, 2017 at 8:30
  • $\begingroup$ @BarbaraKwarc You can have a look at Wikipedia article. Or perhaps this question: Intuition behind “ideal”. $\endgroup$ Mar 20, 2017 at 9:01
7
$\begingroup$

If we take Euclid's algorithm:

$\text{gcd}(a, b) = \left\{ \begin{array}{l l} a & \quad \text{if $b = 0$}\\ \text{gcd($b$, $a$ mod $b$)} & \quad \text{otherwise} \end{array} \right.$

as the definition of GCD, then $\text{gcd}(a, 0) = 0$ for any $a$, because the stopping case of $b = 0$ is reached immediately. If $a = 0$, then we get $\text{gcd}(0, 0) = 0$.

So, it's possible that Wolfram Alpha obtains its result as a side effect of using Euclid's algorithm rather than deliberate thought as to what gcd(0, 0) should return. But it does fortunately coincide with William's “partial order of divisibility” explanation.

$\endgroup$
5
$\begingroup$

Defining $\gcd(a,b)$ for $\def\Z{\mathbf Z}a,b\in\Z$, to be the non-negative generator of the ideal $a\Z+b\Z$ gives $\gcd(a,0)=|a|$ for all $a$, including for $a=0$. Similarly one can define $\def\lcm{\operatorname{lcm}}\lcm(a,b)$ to be the non-negative generator of the ideal $a\Z\cap b\Z$, which gives $\lcm(a,0)=0$ for all$~a$ (note that since this is the only common multiple in this case, it is unlikely to provoke much discussion).

Adding these cases to the usual definitions of the $\gcd$ and $\lcm$ for nonzero integers causes no problems; all usual formulas remain valid. In fact, if one wants the rule $\gcd(xy,xz)=|x|\gcd(y,z)$ to hold for all integers $x,y,z$, one is forced to put $\gcd(0,0)=0$.

On the other hand, I don't think it is absolutely vital for mathematics to have $\gcd(0,0)$ defined, in the same way as $0+0$, $0\times0$ and $0^0$ need to be defined (and $0/0$ needs to be undefined) in order for the usual rules of algebra that one uses all the time to be valid. I think it would suffice to qualify the rule I cited by "$x\neq0$" if one wants to leave $\gcd(0,0)$ undefined; other rules like $\gcd(a,b)=\gcd(a,a-b)$ do not seem to equate $\gcd(0,0)$ with something else. The reason that leaving it undefined is not so dramatic is that when considering divisibility, $0$ is often excluded anyway; for instance it has to be put aside in the theorem of Unique Factorisation.

$\endgroup$
3
$\begingroup$

In the general framework of integral domains (commutative rings with unity, without nontrivial zero-divisors), we define a greatest common divisor of two elements $a,b$ of an integral domain $R$ as any element $c\in R$ satisfying:

  • $c$ divides both $a$ and $b$, that is, there are $x,y\in R$ such that $a=cx$ and $b=cy$.
  • If $d\in R$ divides both $a$ and $b$, then $d$ divides $c$.

We write $c=\gcd(a,b)$ in this case. The definition implies that if $c,c^\prime=\gcd(a,b)$, then $c$ and $c^\prime$ are associates, that is $c=uc^\prime$ for some invertible element $u$ in $R$. This is equivalent to say that the principal ideals generated by $c$ and $c^\prime$ are the same. Therefore a non-ambiguous definition is as follows:

"$\gcd(a,b)$ is $\ $ any minimal$\ $ the minimum element in the family $\mathcal F=\{Rd: Rd\supseteq Ra+Rb\}$ of principal ideals containing $a$ and $b$, ordered by inclusion, wherever such minimum ideal exists."

Since $R0+R0=R0$, we see that $R0=0$, the trivial ideal of $R$, is the $\gcd$ of $0$ and $0$.

In general you cannot guarantee that $\gcd$s exist. A sufficient condition is your integral domain $R$ to be a UFD (Unique Factorization Domain).

$\endgroup$
7
  • 1
    $\begingroup$ Use \gcd instead of $GCD$. Also, ^\prime can be abbreviated all the way down to '. $\endgroup$
    – dfeuer
    Sep 16, 2013 at 5:11
  • $\begingroup$ I've tried editing it myself, but you've interrupted me twice, so I'll let you do it. $\endgroup$
    – dfeuer
    Sep 16, 2013 at 5:11
  • $\begingroup$ @dfeuer Thanks for the suggestion. By the way, that ' shortcut works in ordinary $\LaTeX$? $\endgroup$ Sep 16, 2013 at 5:12
  • $\begingroup$ Yep! It even works in Plain $\TeX$! $x'''$ just takes four keystrokes (six if you count dollar signs). $\endgroup$
    – dfeuer
    Sep 16, 2013 at 5:16
  • 4
    $\begingroup$ anon- Not on my keyboard. On my keyboard, backtick is the key to the left of 1, and tilde is obtained by holding shift and pressing the hash key (which is next to Enter). In general, the location of punctuation characters varies in keyboards used in different countries. $\endgroup$
    – Hammerite
    Sep 16, 2013 at 9:21
1
$\begingroup$

From Wikipedia:

The greatest common divisor of $a$ and $b$ is well-defined, except for the case $a=b=0$, when every natural number divides them.

$\endgroup$
3
  • 4
    $\begingroup$ Well, this isn't really the right answer, is it? William got it right. $\endgroup$
    – user43208
    Sep 16, 2013 at 5:22
  • 2
    $\begingroup$ All I'm saying is that Wikipedia got it wrong in this case (or at least it's misleading to suggest that $\gcd(0, 0)$ is not well-defined, because as has been clearly explained, it's perfectly well-defined and indeed it's $0$). $\endgroup$
    – user43208
    Sep 16, 2013 at 5:32
  • $\begingroup$ The guy got his answer, that's the most important :) $\endgroup$
    – DanielY
    Sep 16, 2013 at 5:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .