# Find perfect square ends with 9009

I am trying to solve the following problem.

Find perfect square which last 4 digit is 9009

The solution in the textbook starts as follows.

Let $$x$$ be the one we want to obtain. Then $$x^2 = 10000y + 9009$$. Then $$x=10a \pm 3$$.

I am confused with the last part. why $$x=10a\pm 3$$?

• Since the square ends in $9$, $x$ must end in either $3$ or $7$.
– lulu
Commented Jan 10, 2020 at 15:13
• @lulu how one can prove that? Commented Jan 10, 2020 at 15:15
• Trial and error. There are only $10$ digits $x$ might end in. Try all of them.
– lulu
Commented Jan 10, 2020 at 15:16
• @lulu thanks, I will try Commented Jan 10, 2020 at 15:17
• @phy_math we can consider all possiblities of the ending digit from 0 to 9 Commented Jan 10, 2020 at 15:17

For any integer $$M$$ there are integers $$a,b$$ so that $$M =10a + b$$ and $$b = 0....9$$.

If $$b >5$$ then $$M = 10(a+1) - (10-b)$$ where $$10-b = 4,3,2,1$$.

So for any integer $$M$$ there are integers $$c,d$$ so that $$M = 10c \pm d$$ and $$d= 0,1,2,3,4,5$$

That means $$M^2 = (10c \pm d)^2 = 100c^2 \pm 20cd + d^2 = 10(10c^2 \pm 2cd) + d^2$$

Now $$d= 0,1,2,3,4,5$$ so $$d^2 = 0,1,4,9,16,25$$.

So if the last digit of $$M^2$$ ends with $$0,1,4,9,6$$ or $$5$$ then $$M= 10c \pm 0,1,2,3,4$$ or $$5$$ respectively. So if $$M^2 = 10000y + 9009$$ then $$M = 10c \pm 3$$.

So we have $$M^2 = (10c \pm 3)^2 = 100c^2 \pm 60 c + 9= 10000y + 9009$$

So $$100c^2 \pm 60c = 10000y + 9000$$. we divide both sides by $$10$$ we get

$$10c^2 \pm 6c = 1000y + 900$$. The right hand side is divisible by $$10$$ we which means $$6c$$ must also be divisible by $$10$$. That means $$c$$ is divisible by $$5$$.

So if we say $$c = 5e$$ then we have $$10*(25e^2) \pm 30e = 1000y + 900$$ and we divide both sides by $$10$$ and get

$$25e^2 \pm 3e = 100y + 90$$. Now the RHS is divisible by $$5$$ so that means $$3e$$ is divisible by $$5$$ which means $$e$$ is divisible by $$5$$. Let $$e = 5f$$. So we have

$$25*25f^2 \pm 15f = 100y + 90$$. Divide both sides by $$5$$ and we get

$$125f^2 \pm 3f = 20y+18$$

Now if $$f$$ is even then $$125f^2$$ will be divisible by $$20$$. And if $$f = 6$$ then $$3f = 18$$. So that will be one possible answer.

If $$f = 6$$ then $$e= 5*f= 30$$ and $$c=5e = 150$$. And $$M=10c + 3 = 1503$$.

And so $$1503^3 = (1500^2 + 2*1500*3 + 3^2) = 2250000 + 9000 + 9 = 2259009$$.

Let $$x=10a\pm b,0\le b\le5$$

$$\implies b^2\equiv0,1,4,9,5\pmod{10}$$

$$x^2=10(10a^2\pm2ab)+b^2\equiv b^2\pmod{10}$$

$$\begin{eqnarray*} 3497^2=12229009. \end{eqnarray*}$$ There could be others.

• actually $3487^2 = 12159169$ Commented Jan 11, 2020 at 5:07