If $\gcd(a, b) = 1$ and if $ab = x^2$, prove that $a, b$ must also be perfect squares; where $a,b,x$ are in the set of natural numbers

Below is an approach employing basic gcd arithmetic (associative, commutative, distributive laws), some of which you may need to (simply) prove before you can use this method. But once you do so, you will gain great power. Below we explicitly show that $\rm\:a,b\:$ are squares by taking gcds. Namely

Lemma $\rm\ \ \color{#0a0}{(a,b,c) = 1},\,\ \color{#c00}{c^2 = ab}\ \Rightarrow\ a = (a,c)^2,\,\ b = (b,c)^2\ $ for $\rm\:a,b,c\in \mathbb N$

Proof $\rm\ \ (a,c)^2 = (a^2,\color{#c00}{c^2},ac) = (a^2,\color{#c00}{ab},ac) = a\color{#0a0}{(a,b,c)} = a.\ $ Similarly for $\,\rm(b,c)^2.\ \ $ QED

OP is the special case $\rm\:(a,b) = 1\ (\Rightarrow\ (a,b,c) = 1)$.

Generally $\rm\: \color{#c00}{ab = cd}\: \Rightarrow\: (a,c)(a,d) = (aa,\color{#c00}{cd},ac,ad) = a\: (a,\color{#c00}b,c,d) = a\:$ if $\rm\:(a,b,c,d) = 1.\:$ For more on this and closely related topics such as Euler's four number theorem (Vierzahlensatz), Riesz interpolation, or Schreier refinement see this post and this post.

The Lemma generalizes from squares to $n$'th powers - see here.


Compare the following Bezout-based proof (this is a simplified form of the proof in Rob's answer). For comparison, I append an ideal-theoretic version of the proof of the more complex direction.

Note that $\ 1=\overbrace{a{\rm u}+b\,{\rm v}}^{\large (a,b)}\,\ \overset{\large \times\,a}\Rightarrow\ a = \color{#c00}{a^2}{\rm u}+\!\!\overbrace{ab}^{\Large\ \ \color{#c00}{c^2}}{\rm v} \ \,$ so $\,\ d=(a,c)\mid a,c\,\Rightarrow\, d^2\!\mid \color{#c00}{a^2,c^2}\,\Rightarrow\, d^2\!\mid a$

Conversely $\ d = (a,c)= au+cv\,\ \Rightarrow\,\ d^2=\,\color{#c00}{a^2}u^2+2\color{#c00}acuv+\color{#c00}{c^2}v^2\ \ $ thus $\ \ \color{#c00}{a\mid c^2}\ \Rightarrow\,\ \color{#c00}a\mid d^2$

$\quad\ \ {\rm i.e.}\quad (d)= (a,c)\ \ \Rightarrow\ \ (d^2) \:\!\subseteq\, (a,c^2)\,\color{#0a0}{\subseteq\, (a)}\ \ $ by $\ \ a\mid c^2\,\ $ [simpler ideal form of prior]

Simpler, by the above Lemma $\, (d)^2 = (a,c)^2 \color{#0a0}{= (a)}.\,$ Note how this ideal version (and above Lemma's gcd version) eliminates the obfuscatory Bezout coefficients $\,u,v,\,$ and, further, allows us to simultaneously prove both directions .


Fundamental theorem of arithmetic says that every number has a unique prime factorization.

If gcd(a,b) = 1, then all of these factors are unique (no prime factor is shared between a and b). What does this say about $x^2$?

Hint 2:

Let $a_i$ be a prime factor of a and $b_i$ be a factor of b. Then,

$$ab = \prod {a_{i}^{m_i}}\prod {b_{i}^{n_i}}$$

But $x$ has to have a unique factorization in the form,

$$ x = \prod {x_{i}^{e_i}} $$, where $m, n, e$ are integer exponents. Keep in mind it is unique and we can order these factors in any way we please. What does this say about $x^2$ compared to $ab$?