## Numbers Which Are Both Squares and Cubes Must be of Form 7k, 7k+1

Suppose a number
$x$
is both a square and a cube. Then we can write
$x=m^2=n^3$
. Only numbers of certain forms can be both a square and a cube. The table shows such numbers modulo 7.
 $m, \; n$ $m^2$ $n^3$ 0 $0 \equiv 0 \; (mod \; 7)$ $0 \equiv 0 \; (mod \; 7)$ 1 $1 \equiv 1 \; (mod \; 7)$ $1 \equiv 1 \; (mod \; 7)$ 2 $4 \equiv 4 \; (mod \; 7)$ $8 \equiv 1 \; (mod \; 7)$ 3 $9 \equiv 2 \; (mod \; 7)$ $27 \equiv 6 \; (mod \; 7)$ 4 $16 \equiv 2 \; (mod \; 7)$ $64 \equiv 1 \; (mod \; 7)$ 5 $25 \equiv 4 \; (mod \; 7)$ $125 \equiv 6 \; (mod \; 7)$ 6 $36 \equiv 1 \; (mod \; 7)$ $216 \equiv 6 \; (mod \; 7)$ 7 $49 \equiv 0 \; (mod \; 7)$ $343 \equiv 0 \; (mod \; 7)$ 8 $64 \equiv 1 \; (mod \; 7)$ $512 \equiv 1 \; (mod \; 7)$ 9 $81 \equiv 4 \; (mod \; 7)$ $729 \equiv 1 \; (mod \; 7)$
From the table, only numbers which have remainder 0 or 1 on division by 7 can be both a square and a cube, so such numbers must be of the form
$7k$
or
$7k_1$
.