[Math] If $a, b$ are relatively prime proof and $ab$ is a perfect square, so are $a$, $b$

elementary-number-theoryexamples-counterexamplesproof-writingsquare-numbers

Prove that if $a$ and $b$ are relatively prime integers and $ab$ is a perfect square so are $a$ and $b$. Show by counterexample that the relatively prime condition is necessary.

I dont know how to start this proof. Also the second "counterexample" part is messing me up. Thanks for any help!

Best Answer

Counterexample (hint): take $a=b$ (hint: not any $a$ will do)

Proof (hint): write $ab=c^2$ and consider the decomposition of $c$ into prime factors; each of these occurs either in $a$ or in $b$ but not in both.