37

I'm sorry to ask this question but it is important for me to know more about number theory.

I'm confused how $0$ is not divided by itself and in Wolfram Alpha $\gcd(0, 0) = 0$ .

My question here is: is $\gcd(0, 0) = 0$ a wrong belief in mathematics or it is true by convention?

Thank you for any help.

Alex M.
  • 35,207
  • 7
    If one decides to define $\gcd(0,0)$, then $0$ is a good choice. One can choose not to define it. – André Nicolas Aug 06 '15 at 14:13
  • 1
    Wouldn't the greatest common divisor be infinite since all numbers go into $0$? – John Douma Aug 06 '15 at 18:38
  • If $m$ is a positive integer, then $\gcd(m, m) = m$. And if $m$ is negative, then $\gcd(m, m) = -m$. From this it would seem natural to conclude that $\gcd(0, 0) = 0$. But that feels like we're jumping to a conclusion. – Robert Soupe Aug 07 '15 at 03:28
  • 7
    You can't divide by $0$, but $0$ is a divisor of $0$, because $0\cdot 0=0$. The relation $a\mid b$ means “there exists $c$ such that $b=ac$”. – egreg Aug 07 '15 at 15:03
  • but i think your relation is works if a\neq 0 – zeraoulia rafik Aug 07 '15 at 15:15
  • 13
    This is one of those situations where archaic terminology obscures what ought to be the right definition. "Greatest" makes people think in terms of the usual "$\leq$" ordering of the natural numbers, rather than the partial ordering by divisibility. "Divisor" makes them think about dividing, with its attendant unpleasantness when $0$ is involved. Once you get past the biased terminology, things clear up considerably, as explained in the answers from egreg and Steven Gregory. – Andreas Blass Aug 07 '15 at 18:16
  • Then why not come up with a new word? I don't have any fancy degrees in math, I'm a normal person, so I expect that when you call something a divisor it's something you can divide by. You don't call a miter saw a crimper and you don't call a crimper a stapler. If it's so important to define this concept in terms of multiplication, then come up with a word that has "multipl" in it. I don't know, multiplicator, multiplier, multiplickee, something. –  Aug 07 '15 at 19:13
  • 1
    @Anthony Nobody is saying $0$ is a divisor of anything but $0$. Rather, everything else is also a divisor of $0$. Andreas is postulating that some may oversimplistically think "division and $0$ in the same context, must be impossible" as an explanation for how some may react to the fact $\gcd(0,0)=0$. – anon Aug 07 '15 at 19:27
  • @AndreasBlass Thank you. That makes sense. Zero is a divisor of $0$ and since all numbers divide $0$, $0$ is maximal in the partial ordering defined by $a\prec b$ if $a$ divides $b$. – John Douma Aug 07 '15 at 20:12
  • @Anthony Your point is reasonable, in that mathematical terminology rarely changes and sometimes outlives its usefulness. On the other hand, I'm not really convinced by your example; how often are miter saws used to saw miters? – Andreas Blass Aug 07 '15 at 23:12
  • 2
    @AndreasBlass I think that they have it stuck in their heads that $b|a$ if and only if $\dfrac ab$ is an integer. Which is mostly but not always true. Then they look at $\dfrac 00$ and get all confused. – Steven Alexis Gregory Aug 11 '15 at 19:05
  • @Anthony. When you were in grade school, and you divided N by d and got q, how did they tell you to check that you were right? – Steven Alexis Gregory Aug 12 '15 at 05:45
  • 1
    @Steven That was so long ago I don't actually remember. I only remember that I disliked math class. –  Aug 12 '15 at 21:14
  • 1
    I remember a pedantic professor of mine insisting that the degree of a non-zero constant polynomial be defined as $0$, and the degree of the constant zero polynomial be defined as $-\infty$.

    In his memory I insist that we define $\mathrm{gcd}(0,0) = \infty$.

    – Umberto P. Aug 14 '15 at 00:34
  • Depending on the definition of GCD, this is either provable or a convention. However, as a justification for the convention, note that $(0,n)=n$ for all non-zero $n\in\mathbb{Z}$. – robjohn Aug 14 '15 at 15:53
  • The "greatest" in GCD means the greatest with respect to the divisibility order, not with respect to the usual order. $0$ is the greatest integer by the divisibility order, since every integer divides $0$ (even $0$ divides $0$, since $0\times 1 = 0$). – Alexey Feb 06 '19 at 16:25
  • Put $,a = 0,$ below (which follows from the definition of a gcd). $$\begin{align} d\mid \color{#0a0}{a,a}! &\iff! d\mid\color{#c00}a\[.2em] \Longrightarrow\ \gcd(\color{#0a0}{a,a})!!! &\ \ \ =\ \ \ \color{#c00}a \end{align}\qquad\qquad $$ – Bill Dubuque Feb 27 '23 at 03:05

11 Answers11

46

It's not a belief. It's not a convention. It can be proved...

Negative numbers would just be an unnecessary distraction. So we will assume that we are talking about numbers in $\mathbb Z^+ =\{0, 1, 2, 3, \dots\}$

There are two conditions that $g$ must meet to be called the greatest common divisor $(\gcd)$ of $x$ and $y$.

\begin{array}{lll} 1. &g|x \text{ and }g|y &\text{(g is a common divisor of x and y)}\\ 2. &\text{If }z|x \text{ and } z|y \text{, then } z|g &\text{(g is the greatest common divisor of x and y)} \end{array}

As an example, consider the numbers $180$ and $216$. The common divisors of these two numbers are $D_{180,216} = \{1,\,2,\,3,\,4,\,6,\,9,\,12,\,18,\,36\}$ The elements of $D_{180,216}$ are all of the numbers that satisfy condition $(1).$

Here is where things get different than you might think they are. Your immediate reaction might be to say that $36$ is the greatest common divisor because all of the other numbers in $D_{180,216}$ are less than $36$. No, that's wrong. Look more closely at condition $(2)$. The reason that $36$ is the greatest common divisor is that all of the other numbers in $D_{180,216}$ are divisors of $36$. This is a much more subtle and sophisticated thing:

Every list of the common divisors of two numbers contains exactly one number that all of the other numbers in that list divide into. That number is the greatest common divisor.

So how do we prove that $\gcd(0,0) = 0$?

It turns out that there are two definitions of $a|b$.

DEFINITION A. Let $a,b \in \mathbb Z^+.$ Then $a|b$ if and only if there exists an $n \in \mathbb Z^+$ such that $b = an$.

DEFINITION B. Let $a,b \in \mathbb Z^+.$ Then $a|b$ if and only if there exists an $n \in \mathbb Z^+$ such that $\dfrac ba = n$.

The two definitions are exactly the same except, by definition A, $0|0$ is true, and by definition B, $0|0$ is at best undefined. Defining $0|0$ to be true makes the two definitions equivalent to each other.

I found that Wolfram's mathworld uses definition B. Wikipedia lists both definitions. Every algebra and number theory book I own uses definition A.

Personally, I am appalled to see definition B because definition A is necessary to generalize the concept of "divides" to principle ideal domains. One other misconception should be addressed here. There seems to be a belief that $a|b$ implies that $a \le b$. That isn't always true. According to either definition, $4|0$ (Since $\dfrac 04 = 0$ and $0 = 4 \cdot 0$) but $4 \nleq 0$.

Since $0 = x \cdot 0$ for all $x \in \mathbb Z^+$, the divisors of $0$ are $D =\{0,1,2,3,4,\dots\}$ So the common divisors of $0$ and $0$ are $D_{0,0}=D =\{0,1,2,3,4,\dots\}$. The one number in that list that all of the other numbers divide into is $0$.

Hence $0 = \gcd(0,0)$.

I suppose the answer to your question is that it depends. If you accept definition(A), then $\gcd(0,0) = 0$ can be proved. If you accept definition(B), then you have to define $\gcd(0,0) = 0$ so that it agrees with the consequences of definition(A).

  • 1
    According to http://mathworld.wolfram.com/Divides.html, $n|0$ for all integers $n$ "by convention", except when $n=0$. Doesn't this mean anything other than $g=0$ satisfies those conditions? – Sultan of Swing Aug 07 '15 at 15:06
  • Also try Divisors[0] in Mathematica or Wolfram Alpha. – Robert Soupe Aug 07 '15 at 15:20
  • 3
    @SultanofSwing In a commutative ring $R$, we have $a\mid b$ by definition if and only if there is a $c\in R$ with $b = ac$. So $n\mid 0$ by definition. Well, one definition. One can make other definitions (but that one is IMO the most natural and convenient), and then it may be a matter of convention. – Daniel Fischer Aug 07 '15 at 15:21
  • @DanielFischer I didn't really quote the page properly. It was probably saying something like "our convention is: $n$ always divides zero unless $n=0$". Yes, certainly $n\mid 0$ by definition. According to an article that is mentioned in that MathWorld page, there is a convention that says zero does not divide zero. So $0$ doesn't satisfy the basic properties of $\gcd(x,y)$ by that convention, and I figured I'd point it out. – Sultan of Swing Aug 07 '15 at 15:25
  • But I would agree that $0 \mid 0$ since $0 = 0 \cdot c$ for any $c$, so I suppose that "convention" doesn't really make much sense in a general commutative ring. – Sultan of Swing Aug 07 '15 at 15:28
  • @SultanofSwing. Pick a number. Say $g=5$ Then $g$ satisfies condition (1) but it does not satisfy conditions (2). – Steven Alexis Gregory Aug 07 '15 at 15:35
  • 1
    I think @SultanofSwing meant that the convention that "zero does not divide zero" doesn't really make sense in their last comment. – Daniel Fischer Aug 07 '15 at 15:37
  • 1
    @StevenGregory I suppose I failed to pay closer attention to condition (2). Doh. Anyways, I just thought I'd point out this "convention" according to "Hardy and Wright 1979, p. 1", that's all. – Sultan of Swing Aug 07 '15 at 15:40
  • @SultanofSwing. Yes. And I wasn't picking up on that. Sorry. – Steven Alexis Gregory Aug 08 '15 at 03:22
  • I diagree with your definition of the gcd. Condition 2 should be "If $z\mid x$ and $z\mid y$, then $z\le g$."; your version of Condition 2 is then a theorem - when $(x,y)\ne(0,0)$. (The "g" in gcd stands for "greatest", after all.) – Greg Martin Aug 12 '15 at 05:17
  • 1
    @GregMartin. If you are only looking at positive integers, then you are right since both definitions coincide. But I you want the entire ring of ingegers or anything more abstract, then you are just wrong.

    see this

    – Steven Alexis Gregory Aug 12 '15 at 05:27
  • @GregMartin. The relation $|$ (divides) is a partial order (up to associates) on the set of integers. Condition (2) says that every other divisor of x and y is also a divisor of g. With respect to the relation $|$, that makes g the "greatest" common divisor. – Steven Alexis Gregory Aug 12 '15 at 05:41
  • @GregMartin. Sorry to pester you again, but I just found this in Wikipedia – Steven Alexis Gregory Aug 12 '15 at 06:52
  • If you think the best response to the OP is to talk about arbitrary rings instead of the integers, I'm not sure we have common ground to reach here. – Greg Martin Aug 12 '15 at 07:20
  • @GregMartin,The war of this question has been finished . – zeraoulia rafik Aug 17 '15 at 23:26
18

Well it depends.

When we define the GCD for two integers, the definition makes sense as long as at least one of the integers is not zero. And whenever when you deal with divisibility problems, $\gcd(0, 0)$ doesn't make sense.

Now, if you know a bit of algebra, there is another way of characterizing (i.e. identifying) the GCD of two integers:

The ideal generated in $\mathbb Z$ by $a$ and $b$ is a Principal Ideal. This ideal is generated by $\gcd(a, b)$ or by $-\gcd(a,b)$. Now, this definition is equivalent to the original one for $(a, b) \neq (0, 0)$ and can be extended naturally to the case $a = 0, b = 0$. With this definition we get $\gcd(0, 0) = 0$.

When using results/tools from Ring theory, one might want to use this convention. This way, one can get slightly more general results, and there is no need to worry at every step if we are in the case $(0, 0)$.

Robert Soupe
  • 14,663
N. S.
  • 132,525
  • +1 for the ring theory point of view. It looks a lot cleaner than all that divisibility stuff. – lisyarus Aug 07 '15 at 15:08
  • 2
    @lisyarus One can define gcds for commutative rings (they don't always exist), but once again the "greatest" part does not mean greatest in the sense of an additive linear ordering - very rarely is there any such ordering! Rather, greatest is again with respect to the divisibility ordering. – anon Aug 07 '15 at 19:46
  • 1
    The beauty of defining $\gcd$, using the ring and ideal structure of $\mathbb{Z}$, is that it can be generalized to commutative rings as anon has pointed out, and that you can define $\text{lcm}$ in a similar fashion. Hence, $\text{lcm}(m,0)=0$ for all $m\in\mathbb{Z}$. – Batominovski Aug 12 '15 at 01:52
12

This is one of those question that raise religious wars. ;-)

The greatest common divisor was considered first when $0$ was not listed among numbers and it was defined as the largest (under the usual ordering) common divisor. But things change over the centuries.

In what follows, number will mean “natural number” (zero included).

Some people say that every nonzero number $n$ divides $0$, because $n\cdot 0=0$, but they don't accept $0\mid 0$. On the other hand, the definition for $a\mid b$ expressed as “there exists a number $c$ such that $ac=b$” clearly includes $0\mid 0$. One could add “unique”, so in this case $0$ would not divide $0$. As you see, it's just a matter of definitions.

Let's consider the usual ordering of numbers:

$a\le b$ if and only if there exists $c$ such that $a+c=b$

If we compare to the above definition of divisibility

$a\mid b$ if and only if there exists $c$ such that $ac=b$

we surely see an interesting similarity. More interesting is that this defines another order relation on numbers: divisibility is reflexive, antisymmetric and transitive. It's not a total order, because $2\nmid 3$ and $3\nmid 2$, but it's a very interesting ordering nonetheless. Indeed, the ordered set of numbers under divisibility is a lattice: any two elements have a greatest lower bound and a least upper bound.

The greatest lower bound of $a$ and $b$ is a number $d$ such that

  1. $d\mid a$ and $d\mid b$ ($d$ is a lower bound)
  2. for all $c$, if $c\mid a$ and $c\mid b$, then $c\mid d$ ($d$ is the greatest lower bound)

Of course, the greatest lower bound of a single element is the element itself.

What's this greatest lower bound? Of course it is the greatest common divisor in all cases when one among $a$ and $b$ is nonzero. And there's no point in excluding the element $0$ which, in this ordering is the maximum element, because $n\mid 0$ for all $a$ (and $1$ is the minimum).

Once we note that this relation on the natural numbers reflects the partial ordering of ideals in the ring $\mathbb{Z}$ of integers with respect to reverse inclusion, this ordering becomes even more interesting, because the greatest lower bound of two ideals is their sum (and the least upper bound is their intersection), which immediately provides the Bézout relation for the greatest common divisor.

Let's get bold. There are (commutative) rings where the notion of “largest” cannot be given a sensible meaning (think to the Gauss integers), but the notion of greatest common divisor makes sense and is very important. We lose uniqueness, but for any two elements $a$ and $b$ we can find one element $d$ satisfying properties 1 and 2 above.

So, in view of this generalization, the “modern” definition of gcd is more useful and, $\gcd(0,0)=0$ makes no problem. From a computational point of view, restraining ourselves to the natural numbers, perhaps the older definition is better and asking about $\gcd(0,0)$ is rather pointless.

Decide what your definition is and act on consequence. That's all. Allowing $\gcd(0,0)$ requires making exceptions to the rule that $a/\gcd(a,b)$ is a divisor of $a$; on the other hand, not defining it requires making different exceptions. I don't think there are better or worse exceptions: it's a matter of conventions. In some areas a convention may be more useful than another. And, at the end, $\gcd(0,0)$ is not a big deal.

Eric Wofsey
  • 330,363
egreg
  • 238,574
  • At the risk of starting another disagreement, I've suggested editing this answer to capitalize "GCD" when not within typeset math. –  Aug 07 '15 at 19:37
  • 2
    I only find one instance of gcd in this answer that is outside of typeset math, and even if there were numerous instances I don't understand why that'd be useful. – anon Aug 07 '15 at 19:49
  • @egreg, The problem how to convince others as students that gcd(0,0) is 0 or it is wrong belief in math,and in your answer you didn't show if it is true or it is wrong – zeraoulia rafik Aug 08 '15 at 00:17
  • 4
    @zeraouliarafik It's neither true nor false: it depends on conventions. My personal opinion is that there's no danger in deciding that $\gcd(0,0)=0$, because I'm convinced that the “right” definition is by means of the divisibility order relation. – egreg Aug 08 '15 at 05:17
  • @egreg. The first time I saw the algebraic definition of gcd was in Moise's calculus book around 1969. Once I worked out what the definition was saying, I was amazed at the sheer chutzpah of that definition. I checked out wikipedia, and they didn't even formally define gcd. I wonder what it woud take to edit the damn thing? – Steven Alexis Gregory Aug 12 '15 at 05:58
7

You're right to be reluctant to accept the validity of $\gcd(0, 0) = 0$. A lot of times, questions about 0 lead to graph discontinuities and existential quandaries.

Given nonzero integers $a$ and $b$, $$\frac{a}{\gcd(a, b)}$$ is a divisor of $a$ and $$\frac{b}{\gcd(a, b)}$$ is a divisor of $b$. Now, think for a moment about $\gcd(a, 0)$ when $a \neq 0$. ProofWiki tells us that $\gcd(a, 0) = |a|$. For example, with $a = -3$ we have $\frac{-3}{3} = -1$, which is certainly a divisor of $-3$, and $\frac{0}{3} = 0$, which we can choose to accept as a divisor of 0 (more on that choice later).

So far we have not triggered the division by zero error. But if we then ask what the divisors of 0 are, then we run into that problem. And then we also have to re-examine the definition of divisor, a definition we take for granted when dealing with positive as well as with negative integers. Given nonzero integers $a$ and $b$, we say $b$ is a divisor of $a$ if $\frac{a}{b}$ is an integer. For example, $-3$ is a divisor of $-27$ since $\frac{-27}{-3} = 9$. But $-6$ is not a divisor of $-27$ because $\frac{-27}{-6} = \frac{9}{2}$, which is not an integer (though it is a rational number).

Furthermore, each positive integer is one of its own divisors, and its list of divisors is a finite sequence. Thus, if $a > 0$, then $\gcd(a, a) = a$. With minor adjustments we can say the same thing for each negative integer. Indeed, if $a \neq 0$, then $\frac{a}{a} = 1$. But as you already know, $\frac{0}{0}$ is undefined or invalid.

So we reach the seemingly absurd conclusion that every positive integer and every negative integer is a divisor of 0, but 0 itself is not its own divisor. Someone commented earlier that this means that $\gcd(0, 0) = \infty$. Or one could say that $\gcd(0, 0) = -\infty$ for the pure heck of it. But neither $\infty$ nor $-\infty$ are specific integers.

No matter how large two positive integers might be, they each still have a finite list of divisors. The intersection of two finite sets is also finite, and can therefore (at least theoretically, in the case of large integers beyond our practical computational ability) be sorted to find a divisor in common that is greater than all the other common divisors.

But 0 has an infinite list of divisors. Even if we accepted 0 as being its own divisor (which we don't), it's still smaller than, say, $5^{4^{3^2}}$. And then there's $5^{4^{3^2}} + 1$, $5^{4^{3^2}} + 2$, etc., ad infinitum. Therefore $\gcd(0, 0)$ is undefined.

This is all fine and dandy, but if you're programming a calculator or a computer algebra system, do you really want to throw an error message for every little undefined thing that comes your way? You also have to consider that programmers like to build functions on top of other functions. If you have to program GCD, do you implement the Euclidean algorithm (which might not always be the most efficient, e.g., two consecutive Fibonacci numbers) or do you build it on top of FactorInteger?

Try computing $\gcd(8, 13)$. The quickest way is to factorize $8 = 2^3$ and note that 13 is prime. Thus $\gcd(8, 13) = 1$. Now try this in Wolfram Alpha: FactorInteger[0]. Is it any wonder that Wolfram Alpha gives you 0 for GCD[0, 0]? Also try

  • Table[GCD[n, n], {n, -10, 10}]
  • Table[GCD[n, n + 2], {n, -10, 10}]

(That second one gives a $-2$ in the middle that sticks out like a sore thumb).

In conclusion, $\gcd(0, 0) = 0$ is wrong, though I don't know if a lot of people believe it. I think that if you choose to treat it as if it were true, it would be for convenience, not convention.

Robert Soupe
  • 14,663
  • thank you very much ,and i think also that is a wrong beliefs – zeraoulia rafik Aug 07 '15 at 15:20
  • 1
    Well the convention also makes sense in the context of ring theory and such. It's along the same lines of "is $1$ prime or not?" You could choose it to be prime, or not, but some things are much easier stated if you assume it is not prime. For instance, the uniqueness part of the fundamental theorem of arithmetic holds. It would not if $1$ was not prime. We'd also have to say "assume $p$ is a prime that is not $1$" in damn near every important theorem. – Cameron Williams Aug 07 '15 at 15:47
  • 2
    @Cameron I think a much closer analogy would be the question "What is $0^0$?" – Robert Soupe Aug 07 '15 at 16:28
  • @RobertSoupe That is definitely a much better analogy. I'm not sure why it didn't occur to me. Good call. – Cameron Williams Aug 07 '15 at 16:39
  • 3
    I surely accept $0$ as a divisor of $0$, so your “we don't” is inappropriate. ;-) – egreg Aug 07 '15 at 17:23
  • 3
    We don't say that b is a divisor of a if a/b is an integer. We say that b is a divisor of a if there exists an integer n such that a = bn. We do this because it avoids having to divide by 0. You said that, if $a, b \ne 0$ then $\dfrac{b}{\gcd(a,b)}$ is an integer. This is true, but it's a theorem not a definition. – Steven Alexis Gregory Aug 07 '15 at 17:33
  • 1
    @Steven That sounds reasonable enough. Are you also going to tell me that $0 > 1$? – Robert Soupe Aug 07 '15 at 17:40
  • 1
    @RobertSoupe. No, I'm going to tell you that $1|0$, which, with respect to "divides", means that $0$ is greater than $1$. – Steven Alexis Gregory Aug 07 '15 at 17:42
  • When you people want to prove someone wrong, you always find a way. –  Aug 07 '15 at 19:15
  • @egreg I just realized that your "we don't" comment was intended for me and, emoticons notwithstanding, you are right. I was suprised to see the internet's definition of 'divides' and even more suprised to find it defined the same way in one of my graduate number theory books. In my defense, category theory, topology, and noneuclidean geometry, for example, all take old, worn out paradigms and replace them with shiny new ones. I had become so accustomed to them, that I had forgotten that there used to be something different. – Steven Alexis Gregory Aug 23 '15 at 09:07
6

We will use
$\mathbb N = \{1, 2, 3, 4, \ldots\}$ (the set of natural numbers) and
$\mathbb W = \{0, 1, 2, 3, \ldots\}$ (the set of whole numbers).

First we will define divides and gcd over $\mathbb N$. Then we will look at some of the consequences of those definitions, and finally we will look for a mathematically sound way to extend the definitions of divides and gcd to $\mathbb W.$


DIVIDES and GCD over $\mathbb N$


DEFINITION $1.1.$ For all $x, y \in \mathbb N,$ we say that $x$ divides $y$, writen $x|y$, if $\dfrac yx$ is in $\mathbb N.$

LEMMA $1.2.$ For all $x, y \in \mathbb N,$ $x|y$ if and only if there exists an $n \in \mathbb N$ such that $y = nx.$

COROLLARY $1.2.A.$ For all $x, y \in \mathbb N,$ if $x|y$ then $x \le y.$

So, for example $3|15$ because $\dfrac{15}{3}$ is a natural number and because $15=3 \cdot 5.$

DEFINITION $1.3.$ For any $n \in \mathbb N,$ we define the divisors of $n$ to be the set $D_n=\{x \in \mathbb N: x|n\}$

THEOREM $1.4.$ For each $x,y \in \mathbb N,$ there exists a unique $g \in \mathbb N$ such that $D_x \cap D_y = D_g.$

Proof. Consider the prime decompositions $x=\prod_{i=1}^{\infty}p_i^{\alpha_i}$ and $y=\prod_{i=1}^{\infty}p_i^{\beta_i}$ where there exists some $N \ge 1$ such that $\alpha_i = \beta_i = 0$ for all $i \ge N.$ It isn't hard to verify that $g = \prod_{i=1}^{\infty} p_i^{\gamma_i}$ where $\gamma_i = \min(\alpha_i, \beta_i)$ for all $i\ge 1$.

DEFINITION $1.5.$ For each $x,y \in \mathbb N, \gcd(x,y)$ is the unique $g \in \mathbb N$ such that $D_x \cap D_y = D_g.$

COROLLARY $1.5.A.$ For each $x,y \in \mathbb N, \gcd(x,y) = g$ if and only if \begin{array}{ll} (1.) & g|x \text{ and } g|y\\ (2.) & \text{If } z|x \text{ and } z|y \text{, then } z \le g \end{array}

COROLLARY $1.5.B.$ For each $x,y \in \mathbb N, \gcd(x,y) = g$ if and only if \begin{array}{ll} (1.) & g|x \text{ and } g|y\\ (2.) & \text{If } z|x \text{ and } z|y \text{, then } z|g \end{array}


How much trouble does trying to handle $0$ cause?


DEFINITION $1.1$ Almost still works with $0$ thrown in. We can claim, for example, that $4|0$ since $\dfrac 04 = 0.$ But, since $\dfrac 00$ is undefined, we can't decide if $0|0$ is True or False.

LEMMA $1.2$ Is the key to the problem. If we convert this lemma into a definition, then we haven't changed how "divides" works for the natural numbers and now, we can demonstrate that $0|0.$

COROLLARY $1.2.A$ is now False since $4|0$ yet $4 \nleq 0.$ But, "divides" is a partial order and, with respect to that order, $4|0$ indicates that 0 is greater than 4.

DEFINITION $1.3$ Would be fine, except it might seem odd that $D_0 = \mathbb W.$

THEOREM $1.4$ is still true.

DEFINITION $1.5$ Will still make sense.

COROLLARY $1.5.A$ would no longer be true.

COROLLARY $1.5.B$ would still work if we claimed that $0|0$


DIVIDES and GCD over $\mathbb W$


So, how are we to handle $0?$ What follows is essentially the modern approach. In this approach, $0|0$ and $\gcd(0,0) = 0.$

DEFINITION $1.1.$ For all $x, y \in \mathbb W,$ $x|y$ if and only if there exists an $n \in \mathbb W$ such that $y = nx.$

So $0|0$ because $0 = 0 \cdot 0.$

DEFINITION $1.3.$ For any $n \in \mathbb W,$ we define the divisors of $n$ to be the set $D_n=\{x \in \mathbb W: x|n\}$

In particular, $D_0 = \mathbb W.$

THEOREM $1.4.$ For each $x,y \in \mathbb W,$ there exists a unique $g \in \mathbb W$ such that $D_x \cap D_y = D_g.$

In particular, $D_0 \cap D_0 = D_0.$

Proof. Use the old proof for $x, y \gt 0.$ The special cases are easy to handle.

DEFINITION $1.5.$ For each $x,y \in \mathbb W, \gcd(x,y)$ is the unique $g \in \mathbb N$ such that $D_x \cap D_y = D_g.$

It follows that $\gcd(0,0) = 0.$

COROLLARY $1.5.B.$ For each $x,y \in \mathbb W, \gcd(x,y) = g$ if and only if \begin{array}{ll} (1.) & g|x \text{ and } g|y\\ (2.) & \text{If } z|x \text{ and } z|y \text{, then } z|g \end{array}

Note that one way to read condition (2) is that it indicates that $g$ is the "greatest" divisor or $x$ and $y$ with respect to the partial order $divides$.

5

This question is strongly related to the question Why doesn't $0$ being a prime ideal in $\mathbb Z$ imply that $0$ is a prime number?. Let me quote a sentence from Pete L. Clark's accepted answer to that question.

Contemporary algebraists often think about factorization as a property of monoids rather than integral domains per se.

I fully agree with this point of view. Thus here we consider $\mathbb{N}$ as a commutative monoid under multiplication. Here is another quote from the same answer.

... Thus we can think of factorization questions as taking place in the cancellative monoid ...

That is, the usual definition considers the cancellative monoid $\mathbb{N} - \{0\}$ still under multiplication. In other words, when dealing with the notions of factorization, prime element, irreducible element, lcm, gcd and so forth on natural numbers, we simply ignore $0$.

Now, this question insists on using $0$, doesn't it? At the level of monoids, a more general question can be asked.

Are there any coherent notions of factorization, prime element, irreducible element, lcm, gcd that work for non-cancellative commutative monoids?

The answer is yes, but it requires to define carefully a few notions. Let $M$ be a commutative monoid with identity $1$. For convenience, I will denote by $\preccurlyeq$ the divisibility relation (that is $a \leqslant b$ if there exists $x \in M$ such that $ax = b$). I will also assume, for simplicity, that $\preccurlyeq$ is a partial order, that is $a \preccurlyeq b$ and $b \preccurlyeq a$ imply $a = b$. This is certainly the case for $\mathbb{N}$.

Then the gcd of a finite family $(x_i)_{i \in I}$ of elements of $M$ can be defined as the infimum (or greatest lower bound) of the set $\{x_i \mid i \in I\}$ with respect with $\leqslant$. Of course, it does not always exist, but in our case, the gcd of $0$ and $0$ exists and is equal to $0$ since $0 \preccurlyeq 0$ and $n \preccurlyeq 0$ for every $n$. This answers the question, but let me go beyond this rather trivial example.

We first need a clean definition of irreducible and prime elements in a commutative monoid:

Definition. An element $x$ is irreductible if, for each finite family $(x_i)_{i \in I}$ such that $x = \prod_{i \in I}x_i$, there exist $i \in I$ such that $x_i = x$.

Definition. An element $x$ is prime if, for each finite family $(x_i)_{i \in I}$ such that $x \preccurlyeq \prod_{i \in I}x_i$, there exist $i \in I$ such that $x_i \preccurlyeq x$.

It is easy to see that every prime element is irreducible, but the converse is not true in general.

Definition. A decomposition of $x$ is a finite family $D = (x_i)_{i \in I}$ of irreducible elements such that $x = \prod_{i \in I}x_i$.

Decompositions of a given element can be compared as follows. Given $D = (x_i)_{i \in I}$ and $D' = (x'_i)_{i \in I'}$ two decompositions of $x$, we say that $D$ is more reduced than $D'$ (notation $D \leqslant D'$) if there exists an injection $\sigma: I \to I'$ such that, for all $i \in I$, $x_i \preccurlyeq x'_i$. One can show that this defines a preorder on the set of all decompositions of a given element. A minimal element of this set is called a reduced decomposition of $x$.

Now comes the main definition.

Definition. A commutative monoid is said to be factorial if each of its elements admits a reduced decomposition.

Note that in a factorial monoid, an element can have several decompositions, but only one reduced decomposition (up to the order of the factors). Here is a simple example.

Let $M = \{1, p, q, r, 0\}$ where $p$, $q$ and $r$ are idempotent $qr = rq = q$ and $pr = rp = pq = qp = 0$. Then $1 \preccurlyeq p \preccurlyeq 0$ and $1 \preccurlyeq r \preccurlyeq q \preccurlyeq 0$, $p$ and $q$ are primes, $r$ is irreducible but not prime. The reduced decompositions of $1$ and $0$ are $1 = \prod_{i \in \emptyset}x_i$ (yes, the empty product is allowed!) and $0 = pr$. $0 = pq$ is another decomposition of $0$, but not a reduced one.

One can show that lcm's always exist in a factorial monoid, but gcd's do not necessarily exist.

J.-E. Pin
  • 40,163
3

One of the very first difficulties in trying to use the Euclidean algorithm to validate $\gcd(0, 0)$ is the problem of division by zero. As a way around this difficulty, I suggest the trial-and-error version of the algorithm.

Instead of trying to compute $a \over b$ to determine $q_1$ for $a = q_1 b + r$, you try setting $q_1 = 1$. If then $r > b$, you increment $q_1$ until $r \leq b$. e.g., $\gcd(24, 10)$, you get $24 = 1 \times 10 + 14$, and since $14 > 10$, you try $24 = 2 \times 10 + 4$.

So for $\gcd(0, 0)$ you get $0 = 1 \times 0 + 0$, concluding that $\gcd(0, 0) = 0$ as desired.


This implementation of the algorithm is of course inefficient for dealing with positive $a$ and $b$. A slight optimization would be this change: "If then $r \geq b$, you increment $q_1$ until $r < b$." But if I had said that from the get-go, it would have created yet another difficulty.

Mr. Brooks
  • 1,098
2

For those who find my previous answer TLDR, here's what it boils down to:

A nonzero integer $a$ has a finite set of divisors, and so does a different nonzero integer $b$. The common divisors of $a$ and $b$ are the intersection of the divisors of $a$ and the divisors of $b$, and this intersection is also finite, which means there is a number among the common divisors that is greater than all the other common divisors: that's the greatest common divisor. If $a = b$, then we only need to look at one set of divisors, which is still finite.

But every integer is a divisor of 0 (except 0 itself). Whatever positive integer we look at, no matter how large and unreachable it may seem to us, is still smaller than the next higher positive integer. Even if we were to accept 0 as its own divisor, it is still smaller than all the positive integers, and therefore it can't be its own greatest common divisor.

Therefore $\gcd(0, 0) = 0$ is wrong. As for why a given computer program would give you that answer, that depends on how the program was written (I go a little more in detail on that in my longer answer).

Robert Soupe
  • 14,663
  • 2
    Sure $0$ is a divisor of $0$. There is a $c\in \mathbb{Z}$ with $0 = 0\cdot c$. There are in fact a lot of such $c$. – Daniel Fischer Aug 07 '15 at 16:43
  • @Daniel Still $0 < 1 < 2 < 3 < \ldots$. – Robert Soupe Aug 07 '15 at 16:45
  • many answers , some told it is true and others told it is wrong , i didn't understand where is the answer that should accept – zeraoulia rafik Aug 07 '15 at 16:47
  • My point is that even if we accept 0 as being its own divisor, it still doesn't change the fact that it's smaller than any positive integer. – Robert Soupe Aug 07 '15 at 16:49
  • 5
    @RobertSoupe But the "greatest" refers to the divisibility preorder, in which $0$ is the greatest integer. Yes, that's not how back in the days people thought about it when the term was coined, but it's the much more general and useful concept. – Daniel Fischer Aug 07 '15 at 16:49
  • @DanielFischer Maybe the asker knows what a preorder is, but I sure don't. Or is that just a fancy term for some really basic concept that I actually do know? – Robert Soupe Aug 07 '15 at 16:57
  • 1
    A reflexive and transitive relation. See wikipedia article. A preorder is "almost a partial order", but you can have $x \leqslant y$ and $y\leqslant x$ without having $x = y$. – Daniel Fischer Aug 07 '15 at 17:03
  • I'd rather take your word for it than Wikipedia's. It seems very strange to me to consider 0 the greatest integer. Does this mean that $\gcd(3, 0) = 0$? – Robert Soupe Aug 07 '15 at 17:35
  • 2
    No, $0 \nmid 3$, so $\gcd(3,0) = 3$ (or, if we look at $\mathbb{Z}$, then $-3$ is also a $\gcd$ of $0$ and $3$). The thing is that if you have general commutative rings in mind, then the divisibility preorder and $\gcd(0,0) = 0$ are the natural way to look at it. If you focus on $\mathbb{N}$ or maybe $\mathbb{Z}$, then the exception for $\gcd(0,0)$ and the natural ordering of integers can be preferable. See also egreg's new answer. – Daniel Fischer Aug 07 '15 at 18:41
  • @DanielFischer, what about the uniqness of c , do you see it's not important ? – zeraoulia rafik Aug 08 '15 at 00:28
  • 2
    @zeraouliarafik Unimportant. In a ring with zero divisors (fun terminology fact: every ring element divides $0$, but not every ring element is a zero divisor), you can't expect uniqueness anyway. – Daniel Fischer Aug 08 '15 at 08:19
2

What is gcd? It is the greatest common divisor. Divisor is something that divides, wholly here. It is defined for natural numbers and $0$ isn't a natural number. Even if you extend it to integers, $0$ cannot divide a number without resulting in undefined. And moreover $0$ over any number is $0$. Thus IMO, $\gcd(0,0)=\infty$.

1

A lightning rod answer: since the Euclidean algorithm is regarded so highly, and not just for boring old $\mathbb{Z}$, if $\gcd(0, 0)$ is valid, then it must be computable using the Euclidean algorithm.

Going by http://mathworld.wolfram.com/EuclideanAlgorithm.html to start off the computation of $\gcd(a, b)$ we set $$q_1 = \big\lfloor \frac{a}{b} \big\rfloor.$$ But $\big\lfloor \frac{0}{0} \big\rfloor$ is undefined, and therefore $\gcd(0, 0)$ must also be undefined.

Lisa
  • 629
  • 1
    The Euclidean algorithm only requires subtraction. Given $(0,0)$ it would output $0$. – ASCII Advocate Aug 14 '15 at 19:23
  • @ASCII After reviewing the Mathworld page Lisa linked, it seems to me like they could be a little clearer on that point. As it stands, it seems perfectly reasonable for someone reading it to conclude that some divisions are required to obtain this thing that's called a divisor. – Robert Soupe Aug 15 '15 at 02:52
  • 1
    I guess "classical" or "Euclid's" Euclidean algorithm would describe more clearly which version I was talking about, that replaces $(a,b)$ with $(a-b,b)$ or $(b,a)$ at every step. That is the one more typical of number theory textbooks and theoretical math conversations, and less typical of actually utilized algorithms run by hand or on a computer. I think the procedure taught in school as part of basic arithmetic, is more often the one that does use integer division. @RobertSoupe – ASCII Advocate Aug 15 '15 at 03:14
  • 2
    This answer misunderstands what $a|b$ means – Squirtle Aug 17 '15 at 19:06
1

Let $D$ be a principal ideal domain; that is, given any ideal $I$ there exists some element, say $a\in I$, such that $I=(a)=\{b.a|b\in D\}$. It follows, by definition, that $\mathbb{D}=(D\backslash \{0\}, \cdot, 1)$ is a commutative cancellation monoid. We define the divisibility relation $a|b$ if and only if $ac=b$ for some $c\in D$. Then $$1|a \text{ and } a|0$$ for any $a\in D$. Define $(D/\sim, |)$ with $a\sim b$ if and only if $a|b$ and $b|a$. Observe $$a|b \text{ if and only if } (a)\supset (b)$$

That is, $[0]$ is the maximum of the ordered set $(D/\sim, |)$ (because $0$ is in every ideal).

Now just apply the definition of "greatest common divisor".

Squirtle
  • 6,698
  • I'm upvoting, but I'm also wondering if it is at all possible to come to this conclusion without ideals, monoids, etc. If Euclid knew English, would this make any sense to him? –  Aug 17 '15 at 21:07
  • 1
    It would be very easy to explain what an ideal, etc... is to Euclid. Also, I think that modern language exists because it works. – Squirtle Aug 17 '15 at 22:59