# Greatest common Divisor of negative numbers

To find gcd of negative numbers we can convert it to positive number and then find out the gcd. Will it make any difference?

• well, take for instance $15,21$, the greatest common divisor is $3$, now the greatest common divisor between $-15,-21$ is still $3$ which is also the greatest common divisor for $15,-21$ and $-15,21$ so no it will not make a difference Commented Jun 4, 2015 at 9:06

It will not make any difference if $gcd(a,b) = d$ then $d \mid a$ and $d \mid b$ and if there exists another integer $c \mid a,b$ then $c \mid d$. Now , $d \mid -a,-b$ as well and if $c \mid -a,-b$ then $c \mid d$ and so $$d = gcd(-a,-b) = gcd(-a,b) = gcd(a,-b) = gcd(a,b)$$

In the general theory of greatest common divisor we can define an element $d$ to be a greatest common divisor of $a$ and $b$ if

1. $d$ divides both $a$ and $b$
2. for all $c$, if $c$ divides both $a$ and $b$, then $c$ divides $d$.

If we stick to the natural numbers, we see that a unique greatest common divisor exists for all pairs of numbers.

The situation is more complicated when we try to extend the theory to arbitrary integral domains.

If we go to the integers, there are generally two. For instance, if $a=4$ and $b=6$, both $2$ and $-2$ satisfy the conditions above.

It's even worse in the case of polynomials (say over the reals): if we consider $f(X)=X^2-3X+2$ and $g(X)=X^2-X$, then any polynomial of the form $a(X-1)$ (for a real $a\ne0$) satisfies the conditions for being a greatest common divisor.

What happens is that whenever $d$ is a greatest common divisor of $a$ and $b$ and $u$ is an invertible element, then also $ud$ is a greatest common divisor as well.

It's however easy to show that, in an integral domain, if a greatest common divisor $d$ of $a$ and $b$ exists, then any other is of the form $ud$ for $u$ an invertible element.

In some cases we are able to add a further condition to guarantee uniqueness. For instance, in the integers we can impose that a greatest common divisor should be nonnegative; in the ring of polynomials over the reals (or any field), uniqueness is usually guaranteed by choosing the monic greatest common divisor (with the exception of the greatest common divisor of $0$ and $0$, which is of course $0$).

In the ring of Gaussian integers $\mathbb{Z}[i]$ the invertible elements are $1$, $-1$, $i$ and $-i$ and there's no sensible way to define a greatest common divisor so as to get some uniqueness.

As you see, it's a matter of conventions. It's better if we can add a condition that gives uniqueness, so we can define a bona fide operation, but actually it doesn't really matter from the theoretical point of view.

No.

If $\langle a,b\rangle\in\mathbb Z\times\mathbb Z-\{\langle0,0\rangle\}$ then $\gcd\left(a,b\right)$ can be defined as the smallest positive element of set $\left\{ ra+sb\mid r,s\in\mathbb{Z}\right\}$.

Note that this set remains the same if $a$ is replaced by $-a$ and/or $b$ is replaced by $-b$.

I'm perfectly content with the answer given by @drhab .

But I can't get that, for $$a,b$$ any two positive integers given, if $$gcd(a,b) = d$$ then $$gcd(a,b) = -d$$ too. Appearently, I have a problem with the word "greatest", which here isn't assigned as a term to indicate any ordering; and this feels wrong with our elementary definitions.

• Nowhere in drhabs answer does s/he say $\gcd(a,b)=\pm d$. Indeed what s/he said was, in essence $\gcd(\pm a, \pm b) = |d|$. THe terms $a,$ and $b$ that you are finding the greatest common divisor OF make no difference whether they are positive or negatives. But $d$, the number that IS the greatest common divisor must be positive. Commented Dec 27, 2018 at 5:32
• @fleablood Actually, I was refering to my own book. Yes, I said that the answer drhab gave defines concisely every aspect of the situation, in the most general theoretical notation. Indeed, the other answer given by alkabary shows it all: $d = gcd(a,b)$ if (1) $d | a$ and $d | b$ and (2) if any other $d_2 = gcd(a,b)$ exists, then $d_2 | d$.So suppose we really have a $c = gcd(a,b)$ which is known to be also $d$; then $c | d$, and $d | c$ too. so $c = +/- d$. So theory says: The gcd is defined up to sign. Commented Dec 27, 2018 at 5:50
• Then I don't understand what you are asking. If $c$ "is known to be $d$" then $c=d$. and we don't have check whether $c|d$ or $d|c$. If on the other hand we are told $c|d$ and $d|c$ then we can conclude $c = \pm d$ and that has nothing to do with $a,b$. If we are told $c=\gcd(a,b)$ then we know $c$ is positive but we don't know if $d$ is. Commented Dec 27, 2018 at 6:39