Let $n$ be an integer and assume that $30$ is a factor of $n^2$ and $15$ is a factor of $n$. Prove that $30$ is a factor of $n$.
I tried testing some numbers, e.g., $n = 30$ clearly works since $15|30$ and $30|30^2$. Also $n = 60$ works. But, how can I prove this generally?