Did I do this proof right? I am not sure if I did the proof right, so I wanted to see how most of you did this. I am trying to solve this problem:
Let $x, y \in \mathbb N$  be relatively prime. If $xy$ is a perfect square, prove that $x$ and $y$ must be both perfect squares.
Here is my proof:
If $x$ and $y$ are both relatively prime, then if a $p_i | x$ then $p_i$ does not divide $y$ and vice versa. Then by FTA, $xy = p_{i_0}p_{i_1} ...$ and this is the only unique factorization of $xy$.Then if $xy = n^2$ for some number n, then $xy = p_{g_0}^2p_{g_1}^2...$ So if $p_{l} | xy$ then $p_l^2 | x $ or $y$ Therefore both x and y are a product of primes squared. Therefore both x and y are perfect squares.
Thanks.
 A: Your proof does not suffice. At the end, your conclusion that if a prime $p|xy$, then $p^2|x$ or $p^2|y$ is correct, but it doesn't exclude, for instance, that $p^3|y$ but $p^4\not| y$, in which case $y$ wouldn't be square.
However, you're going in the right direction. Notice that we can write
$$x=p_1p_2p_3\ldots p_i$$
for some primes $p_i$ and
$$y=q_1q_2q_3\ldots q_j$$
for some primes $q_j$ distinct from any $p_i$. This means that
$$xy=p_1p_2p_3\ldots p_i q_1 q_2 q_3\ldots q_j$$
and, by hypothesis that $xy$ is square, each prime must appear an even number of times - but since any given prime can only appear in either the sequence $p$ or in $q$, it follows that each prime dividing $xy$ appears an even number of times in the sequence $p$ or $q$, implying further than any prime dividing $x$ appears an even number of times in $p$ and any prime dividing $y$ appears an even number of times in $q$. Thus, $x$ and $y$ must be square.
This is essentially the same as your proof, just without appealing to divisibility conditions at the end, and replacing anything to do with primes appearing twice with them appearing an even number of times.
A: For each prime $p$, let $\nu_p(x)$ denote the largest power of $p$ that divides $x$. Note that for any $x,y$, we have that $\nu_p(xy)=\nu_p(x)+\nu_p(y)$. Saying that $x$ and $y$ are relatively prime means that for each prime $p$, $\nu_p(xy)$ is either $0$ or one of $\nu_p(x)$, $\nu_p(y)$, indeed: for example, if $p$ divides $x$, then it cannot divide $y$, so $\nu_p(xy)=\nu_p(x)$. 
By hypothesis $\nu_p(xy)$ is even for each prime $p$, so the above implies that for each prime $p$, $\nu_p(x)$ and $\nu_p(y)$ are even, since they equal $\nu_p(xy)$.
In fact, if $x,y$ are coprime, $\nu_p(xy)=\nu_p(x)+\nu_p(y)=\max(\nu_p(x),\nu_p(y))$ for each prime $p$. Saying $x,y$ are squares is the same as saying $\nu_p$ is even for each prime $p$, for both $y$ and $x$. 
