# Can we find the GCD of a positive and negative number?

I'm trying to evaluate whether or not $\gcd(p,q) = \gcd(-p,q)$ for non-zero integers $p$ and $q$.

I was wondering if it's possible to find $\gcd(-p,q)$.

If so, this statement should be true, correct?

• If we define $\gcd(a,b)$, where $a$ and/or $b$ may be negative, in the usual way (greatest common divisor), then it is not hard to show directly from the definition that $\gcd(a,b)=\gcd(|a|,|b|)$. Sep 11, 2014 at 2:21
• The prescription Andre gives is also consistent with Bezout's theorem, since if $ap+bq=gcd(p,q)$ then $(-a)(-p)+bq=gcd(p,q)$ as well. Sep 11, 2014 at 3:25
• Sep 11, 2014 at 3:49
• Oh! yes. The word "greatest" . Mar 1, 2015 at 9:48
• Easy answer. Sign doesn't matter $\gcd(\pm a, \pm b) = \gcd(a,b)$. If you feel weird about that just keep in mind if $n|m$ so $m = kn$ then $-n|m$ ans $m = (-k)(-n)$ and $n|-m$ as $-m = (-k)n$. Aug 23, 2016 at 6:36

Somebody has a good proof on proofwiki which makes sense to me. It shows that $$\gcd\{a,b\}=\gcd\{|a|,b\}=\gcd\{a,|b|\}=\gcd\{|a|,|b|\} .$$
Define the $$\gcd$$ like a categorial universal property. This avoids having to make use of an ordering $$\leq$$ on the ring in which you desire a $$\gcd$$.
Let $$R$$ be a commutative ring with $$1$$.
Define $$\gcd(a,b)$$ to be any element $$d \in R$$ such that $$d \mid a, b$$ and if $$e \mid a,b$$ then $$e \mid d$$.
Then when $$R = \Bbb{Z}$$, $$\gcd(-n, m),$$ for $$n,m \gt 0$$ always has two elements, but they are "isomorphic" meaning they're the same upto a unit factor: $$d = (-1)d'$$.
So simply define $$\gcd$$ as you do "product" in a category i.e. there can be many products of objects $$A, B$$ but they are all isomorphic.