# Finding the smallest perfect square whose last 3 digits are the same. How do I do this by hand?

What is the smallest perfect square whose last 3 digits are all the same digit?

After testing different numbers with a calculator, I have found that $$38^2=1444$$ is the smallest...how would you do so without using a calculator? I've tried writing as

$$A \cdot 10^3 + 111 \cdot B = k^2$$ and playing around with it, taking mod $$3$$ and $$37$$ (since $$111=3\cdot37$$), but those have yielded nothing...

Also, I know it must be 4 digit since $$100^2=10,000$$ is also a perfect square with its last 3 digits the same.

• Once you know it is 4 digits, then since $\sqrt{1000}$ is about 33 so even if you have to multiply by hand, it won't take you long to find 38.
– Ted
Commented Jul 29 at 23:56
• You are trying to find the smallest so it makes sense to start with 33, 34, 35...
– Ted
Commented Jul 30 at 0:07
• Joke answer: $0^2=000$. Commented Jul 30 at 0:09
• Based on Mathematica experiments, I'd conjecture that 38 is in some sense the "only" nontrivial example. Specifically, any other example I've found is either of the form $n=100k$ (so $n^2$ ends in 000) or $n=\pm 38\mod{500}$. Commented Jul 30 at 0:25
• @Semiclassical: according to my answer, the last three digits are $000$ or $444$, and the solutions to $n^2\equiv444\bmod1000$ are precisely $n\equiv\pm38\bmod500$ Commented Jul 30 at 13:23

As pointed out by heropup in an answer that has now been deleted, the last digit of a square must be $$0, 1, 4, 5, 6,$$ or $$9.$$ But the last two digits of a square must leave remainder $$0$$ or $$1$$ when divided by $$4$$, so they can’t be $$11$$, $$55$$, $$66$$, or $$99$$. That leaves $$000$$ (which probably doesn’t count), $$444$$, $$1000$$, $$\color{red}{1444}$$

Assuming that $$A = 0$$, that is $$k^2 = B\cdot111$$, we arrive at a contradiction since $$B \in \{0, \ldots, 9\}$$ (and assuming $$k$$ is taken to be nonzero).

If $$A = 1$$, then $$k^2 = 1 \mod 37$$, so $$(k+1)(k-1) = 0 \mod 37$$. And because $$37$$ is prime, $$k = \pm 1 \mod 37$$. In other words $$k = 37x \pm 1,$$ for some integer $$x \in \{1, 2\}$$ (as $$k \leq 100$$). The case $$x = 1$$ includes the correct value of $$k = 38$$.

Let us note the 2-digit number $$k = 10a + b$$ and let's suppose that $$k^2 = 100a^2 + 20ab + b^2$$ has the last 3 digits being the same.

Then the last two digits must have the same parity, but the $$100a^2 + 20ab$$ part cannot change the parity of these digits, so actually $$b^2$$ must have $$2$$ digits of the same parity !

We can then eliminate $$1^2 = 01$$, $$3^2 = 09$$, $$4^2 = 16$$, $$5^2 = 25$$, $$6^2 = 36$$, $$7^2 = 49$$ and $$9^2 = 81$$ because the 2 digits have different parity.

This leaves only $$b = 0$$, $$2$$ or $$8$$ as possibilities, thus we have the repeating digit $$B = 0$$ or $$4$$.

If we start from $$k = 32$$ to have $$k^2 \gt 1000$$, we stumble pretty quick on the correct answer $$k=38$$.

• What about $b=0$? Commented Jul 30 at 13:03
• Ooops good point, adding the case $b = 0$ Commented Jul 30 at 13:29
• I like your reasoning (+1), but I think you should replace the last paragraph with more of your reasoning: If $b=0$ then the smallest non-zero solution is $100^2$. If $b=2$ then the last two digits are $12$ or $62$. However $12^2=144$ so whatever the remaining digits, the "hundreds" digit will always be odd. If the last two digits are $62$ then the last three have to be $462$ or $962$, of which $462^2$ gives us the smallest answer. This leaves $b=8$. The last two digits are $38$ or $88$. However $88^2=7744$, whose third digit is odd, so no solutions will end $88$. $38^2= 1444$.
– tkf
Commented Jul 30 at 16:25
• So the smallest solution is $38^2$, $100^2$ or $462^2$, of which $38^2$ is clearly the smallest.
– tkf
Commented Jul 30 at 16:27
• In fact you get a complete list of three digit solutions: $38, 538, 462,962, 100,200,300,400,500,600,700,800,900$, which I see has already been enumerated [email protected].
– tkf
Commented Jul 30 at 16:36