# If an integer number is a square and a cube, then it can be writen as $5n,5n+1$, or $5n+4$

I want to show that if an integer number is a square and a cube, then it can be writen as $5n,5n+1$, or $5n+4$.

I tried the following. There are integers numbers $x,y$ such that $n=x^{2}=y^{3}.$ By using Euclidean division, then $x$ and $y$ can be writen as $5k,5k+1,5k+2,5k+3$ or $5k+4.$ If $x=5k$ and $y=5l$ we have $n=5(5k^{2})=5(5^{2}l^{3})$. If $x=5k$, then we must have $y=5l.$ I don't know what to do. Any hint?

-
Use unique factorization to see that if $n$ is both a square and a cube, then it must be a sixth power. Then show that $(5k+r)^6$ has one of those three forms for $r=0,1,2,3,4$. –  Brian M. Scott May 21 '12 at 21:29
Try listing the first few squares and cubes and seeing what remainder you get when you divide by 5. That should not take long and may reveal a pattern you can prove. –  Mark Bennet May 21 '12 at 21:30
The y^3 restriction is irrelevant. $0^2 \equiv 0 \pmod 5,$ then $1^2 \equiv 1 \pmod 5,$ then $2^2 \equiv 4 \pmod 5,$ then $3^2 \equiv 4 \pmod 5,$ then $4^2 \equiv 1 \pmod 5.$ Or, for instance, if $x = 5 k + 1,$ then $x^2 = 25 k^2 + 10 k + 1 = 5 (\mbox{stuff}) + 1.$ Or, if $x = 5 k + 3,$ then $x^2 = 25 k^2 + 30 k + 9 = 5 (\mbox{stuff}) + 4.$ –  Will Jagy May 21 '12 at 21:34

Already if an integer is a square it must be of the shapes you have described.

It is easiest to prove this using congruence notation. Any integer is congruent to $0$, $1$, $2$, $3$, or $4$ modulo $5$. Note now that $0^2$, $1^2$, $2^2$, $3^2$, and $4^2$ are respectively congruent to $0$, $1$, $4$, $4$, and $1$ modulo $5$, so never to $2$ or to $3$ modulo $5$.

If we do not want to use congruence notation, calculate the remainder when $(5k)^2$, $(5k+1)^2$, $(5k+2)^2$, $(5k+3)^2$, and $(5k+4)^2$ are divided by $5$. As a sample, let's do it for $(5k+3)^2$. This is $25k^2+30k+9$, which is $5(5k^2+6k+1)+4$, so it has remainder $4$ on division by $5$.

Out of curiosity, let us explore the cubes modulo $5$. Note that $0^3$, $1^3$, $2^3$, $3^3$, and $4^3$ are congruent respectively to $0$, $1$, $3$, $2$, and $4$ modulo $5$. So, unlike squares, cubes can take on any value modulo $5$.

By looking at the numbers $0$, $1$, and $64$, which are all perfect squares and perfect cubes, we can see that indeed a number which is a perfect square and a perfect cube can be of any of the shapes described.

-
Hint $\$ The squares mod $5$ are $\rm\:\{0,\pm1, \pm2\}^2 \equiv \{0,1,4\},\:$ so the cube condition is redundant.