The following question is from Pinter's Abstract Algebra:
Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Prove $c = \gcd(a,b)$.
The definition of greatest common divisor is the usual two conditions:
(1) $c$ is a common divisor of $a$ and $b$; and
(2) any common divisor of $a$ and $b$ must divide $c$.
Further, here $\gcd$ means the greatest common positive divisor.
I just can't seem to figure out how to approach the problem.
I've tried starting with the following idea: if we have $x|a \iff x|c$, then we have that either $a|c$ or $c|a$. Similarly, $b|c$ or $c|b$.
If I could then deduce that $c|a$ and $c|b$ then it would be possible to almost conclude it there, but there appears to be no way to get to this point.
Any help would be appreciated, thanks.