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?

  • 5
    $\begingroup$ 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|)$. $\endgroup$ Sep 11, 2014 at 2:21
  • 2
    $\begingroup$ 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. $\endgroup$ Sep 11, 2014 at 3:25
  • 1
    $\begingroup$ Check my animated answer. $\endgroup$ Sep 11, 2014 at 3:49
  • 1
    $\begingroup$ Oh! yes. The word "greatest" . $\endgroup$
    – PleaseHelp
    Mar 1, 2015 at 9:48
  • 1
    $\begingroup$ 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$. $\endgroup$
    – fleablood
    Aug 23, 2016 at 6:36

2 Answers 2


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.