Find all $4$ digit numbers that are perfect squares and written with $4$ even integers

discrete mathematicselementary-number-theory

Find all $4$ digit numbers that are perfect squares and written with $4$ even integers.

I let the digits be $2p,2q,2r,2s$, starting from the thousands place. Then I expanded the number as $2(1000p+100q+10r+s)$. But since the number is a perfect square, the term inside the bracket must also be divisible by $2$. Hence, $s=2n$. Thus last digit is $=0,4,8$ only.

Now we have $4(500p+50q+5r+n)$. The number inside the bracket must individually be a perfect square. We know that a perfect square can only leave residue of $\equiv 0,1,4\bmod 5$ $\implies n \equiv 0,1,4\bmod 5$.

But, $0≤2s≤8 \Rightarrow 0≤2(2n)≤8 \implies 0≤n≤2$ Hence $n \equiv 0,1,\bmod 5$ only.

Case 1: $n \equiv0\bmod 5$

$500p+50q+5r+0$ is multiple of $5$ hence also must be multiple of $25$, only possible if $r=0$
$\implies n,r=0$. If last two digits are $0$ then we only need to check $40^2,60^2,80^2$. We see that only $80^2=6400$ is possible.

Case 2: $n \equiv1\bmod 5$

Here I am stuck as to what I can do. One option is just checking all the squares from $32 \rightarrow 99$ according to the needed conditions. Can someone suggest a better way?

Best Answer

"Here I am stuck as to what I can do. One option is just checking all the squares from 32→99 according to the needed conditions. " Well, don't check the odd ones. And don't check $\sqrt{1000} \le n^2 \le \sqrt {1999}$ or $\sqrt{8889}\le n^2 \le \sqrt{9999}$ so that tells us to only check $46$ through $94$.

Let $n = 10a + b$ then $(10a + b)= 100a^2 + 20ab + b^2$

$b^2 = 0,4,16,36,64$. Now if $b = 4$ or $6$ then $b^2$ will cause an odd digit to be carried of the the tens place. And the tens place will be determined by $2ab$ plus the odd number added. This results in an odd number. So that is impossible.

$b^2 = 0,4,$ or $64$ and $b= 0,2,$ or $b=8$.

If $b = 0$ then we need $a^2=0,4,16,36,64$ to be a perfect square with two even digits. That can only be $a = 8$. So

So $80^2 = 6400$ is one such number.

Now we just need to check $48, 52,58, 62,68, 72,78,82,88,92$.

But $2889...3999$ all have od digits so we don't have to check $53.. 63$. Or $\sqrt {4889}...\sqrt{5999}$ or $70... 77$. Or $\sqrt{6889}...{7999}$ or $83..89$.

So we only need to check $48,52,78,82,92$

$(10a + 2)^2 = 100a^2 + 40a + 4$ which means the value carried by $4a$ whether odd or even must make $a^2$ odd of even. so the digit carried by $4a$ and an d $a$ must be the same parity.

$4\cdot 5=20$ so $2$ is even but $5$ is odd. So $(50+2)^2 = 2500 + 40\cdot 5 + 4$ so the $2$ carried by $40\cdot 5$ to $2500$ will make $2700$ i.e $2704$.

$4\cdot 8 =32$. The $3$ is odd but $8$ is even so the first two digits of $82^2$ will be $8^2 +3$ which is odd.

$4\cdot 9=36$ and $3$ is odd as is $9$ so this is good. $92^2 = 8100 + 360 + 4=8464$ with the $3$ and 81$ combining to make an even.

That just leaves $48$ and $78$ to check. It's easier to just check them then to make a carrying rule. $48^2 = 2304$. Nope. and $78^2=6084$. Good.

So $80^2 = 6400,92^2 = 8464$ and $78^2 = 6084$ are the only $3$.

Related Question