# Let $n$ be a 6-digit number, perfect square and perfect cube. If $n-6$ is not even or a multiple of 3, find $n$

Let $n$ be a 6-digit number, perfect square and perfect cube. If $n-6$ is not even or a multiple of 3, find $n$.

My try

Playing with the first ten perfect squares and cubes I ended with:

The last digit of $n \in (1,5,9)$

If $n$ last digit is $9$, then the cube ends in $9$, Ex: if $n$ was $729$, the cube is $9^3$ (ends in $9$) and the square ends in $3$ or $7$

If $n$ last digit is 5, then the cube ends in 5 and the square ends in 5

If $n$ last digit is 1, then the cube ends in 1 and the square ends in 1

By brute force I saw that from $47^3$ onwards, the cubes are 6-digit, so I tried some cubes (luckily for me not for long) and $49^3 = 343^2 = 117649$ worked.

So I found $n=117649$ but I want to know what is the elegant or without brute force method to find this number because my method isn't very good, just pure luck maybe.

Note that the required number is both a square and a cube, so it must be a sixth power. Already $10^6=1000000$ has seven digits and $5^6=15625$ has only five digits, so that leaves us with $6^6,7^6,8^6,9^6$ to test.

Furthermore, we are given that $n-6$ is not even and not a multiple of 3, which implies that $n$ itself is also not even and not a multiple of 3. This eliminates $6^6,8^6$ and $9^6$ immediately, leaving $7^6$ as the only possible answer.

• Pretty clever, i don't know how i didn't think about that. Thanks – Rodrigo Pizarro Feb 15 '18 at 2:29

If $n$ is both a perfect square and perfect cube then. $n = a^6$

If $n-6$ is neither even nor divisible by $3$, then $n$ is not even nor divisible by $3$ and $a$ is not even or divisible by 3.

$a^6$ is a $6$ digit number

$6<a<10$

$7$ is the only integer in that interval that is not divisible by $2$ or by $3.$

$n = 7^6$