Prove that if $a \mid b$ then $\gcd(a,b) = |a|$ I am having trouble completing the proof if $a \mid b$ then $\gcd(a,b) = |a|$.
My attempt:
If $a\mid b$ there is a $k \in \mathbb{Z}$ such that $b = ak$. Let $d = \gcd(a,b)$. Then $d \mid a$ and $d\mid b$ so by hypothesis we have $d\mid a$ and $d\mid ak$. Hence, $d \leq \gcd(a,ak)$. We can easily see that the largest common denominator of $a$ and $ak$ is $|a|$, thus $d \leq\gcd(a,ak) = |a|$ so $\gcd(a,b) \leq |a|$.
I am stuck and not sure how to show the reverse inequality $|a| \leq \gcd(a,b)$ to complete the proof.
Clearly $|a|$ is a divisor of $a$.
Also, since $b=ak$. We have $b=\operatorname{sign}(b)|a||k|$, that is $|a|$ is a divisor of $b$.
Hence as a common divisor of $a$ and $b$., it is at most the greatest common divisor of $\gcd(a,b)$.
$$|a| \le \gcd(a,b)$$
&quot;such that b=ak.... d≤gcd(a,ak)

You seem to be overlooking that if $b = ak$ then ..... $b = ak$!
So if $b=ak$ then $\gcd(a,b) = \gcd(a,ak)$.   There is not need to conclude that if $d = \gcd(a,b)$ then $d \le \gcd(a,ak)$.  If $d=\gcd(a,b)$ and $b  = ak$ then $d$ EQUALS $\gcd(a,ak)$.
But I can not accept your claim &quot;We can easily see that the largest common denominator of $a$ and $ak$ is $|a|$&quot;.  I think that is the entire point of the proof and must be spelled out.  (I have an explanation below)
====== Complete Answer======
Dont let the absolute value throw you.  The integer factors of a negative number are exactly the same as the factors of the equivalent positive number (i.e. the absolute value), and if $d$ is a factor of an integer then $-d$ is as well, and positive numbers are larger than even numbers so a $\gcd$ is always positive. We can assume without loss of generality all numbers are non-negative.
If $|a| = a'&gt;0$ and $|b| = b' \ge 0$ then $a|b \iff a'|b'$ and $\gcd(a,b) = \gcd(a',b')$ by the argument in the paragraph above.  So we just need to prove the following.

if $a$ and $b$ are non-negative integers and $a|b$ then prove $\gcd(a,b) = a$.

Pf:  Well, $a = 1\cdot a$ so $a|a$ and $a|b$ so $a$ is a common divisor.  We know that $a\ne 0$ because $0$ does not divide anything.  If $d &gt; a$ then $0 &lt; \frac ad &lt; 1$.  But there is no such integer so $d\not \mid a$.  So $d$ is not a common divisor of $a$ and $b$.  So the greatest common divisor of $a$ and $b$ is $a$.
This assumes your definition of $\gcd(a,b)$ is the largest common divisors of $a$ and $b$.  Many texts uses $\gcd(a,b)$ is the positive common divisor so that every possible common divisor is a divisor of $\gcd(a,b)$.
Proof using that definition:   Now $a$ is a common divisor of $a$ and $b$ so by this definition of $\gcd$ we must have $a|\gcd(a,b)$.  If $a &gt; \gcd(a,b)$ then $a\not \mid \gcd(a,b)$ so $a \le \gcd(a,b)$.  And if $a &lt; \gcd(a,b)$ then $\gcd(a,b) \not \mid a$ and $\gcd(a,b)$ is not a common divisor of $a$ and $b$.  So $a \ge \gcd(a,b)$.  So $a \ge \gcd(a,b)$ and $a \le \gcd(a,b)$.  So $a = \gcd(a,b)$.