# How many four digit numbers are perfect square whose first and last two digits are same?

I tried it by assuming the number as $\sqrt{1100a+11b}$ and than tried to find figure out perfect square but I am unable to approach further.

• Can't you just brute force the problem? You only need to check the numbers $32^2, 3^2,\dots, 100^2$, and a program can do that in no time... – 5xum Jul 14 '15 at 11:15
• You can deduce that $b \in {3,4,7,8}$ – JukesOnYou Jul 14 '15 at 11:21
• You know that $1100\cdot a + 11\cdot b$ is a multiple of $11$. That reduces the search space considerably. – Daniel Fischer Jul 14 '15 at 11:21
• So there are four cases $(8,3),(7,4),(4,7),(3,8)$ you can check this by hand – JukesOnYou Jul 14 '15 at 11:24

As

$$\sqrt{1100a+11b}=\sqrt{11(100a+b)}$$

To make the expression an integer, we may write

$$100a+b=11k^2,k\in{\Bbb{N}}$$

Also as $a,b\le9$, we have

$$100a+b=11k^2\le909$$

Furthermore, as $1000<1089=33^2$, we have $a\ge3$.

So $300\le100a+b=11k^2\le909$

And with some easy observation, we know that $6\le k<10$.

Obviously, only when $k=8,11k^2=704\implies a=7,b=4$.

So the number is $7744.$

A brute force approach yields only one answer: $7744=88^2$.

The program that found this answer is (in Python):

def get_digit(x, k):
return (x % 10 ** k - x % (10 ** (k-1))) / 10 ** (k-1)

for i in range(1, 100):
x = i * i
if get_digit(x, 1) == get_digit(x, 2) and get_digit(x, 3) == get_digit(x, 4):
print x

It's not optimized, but it's very very simple and returns the result almost instantly.

It's easy to solve the problem with brute force, but here is a handmade solution. So, we are trying to find integers $a,b,x$ so that $1100a+11b=x^2$, $x>0$, $1\leq a\leq9$ and $0\leq b\leq9$. (In fact, we must have $30<x<100$.)

Considering the equation modulo 11, we get $x^2\equiv0\pmod{11}$. It is easy to check (there are only 11 cases, or one could use the fact that 11 is square free) that this implies $x\equiv0\pmod{11}$. Therefore $x=11y$ for some $y\geq1$. Plugging this into the equation gives $100a+b=11y^2$. Since we must have $x<100$, we must have $y\leq9$. Now there are only nine cases to check, and it should be easy enough to find all solutions by hand.

Even this amount of brute force can be avoided. From our new equation $100a+b=11y^2$ we get $b\equiv 11y^2\pmod{100}$. Therefore $b\equiv y^2\pmod{10}$ and the only squares modulo 10 are easy to find, so $b\in\{0,1,4,5,6,9\}$. We also get $b\equiv -y^2\pmod{4}$, and the only squares modulo 10 are 0 and 1, so $b\in\{0,3,4,7,8\}$. Combining these two conditions gives $b\in\{0,4\}$. If $b=0$, then from the condition $1100a=x^2$ we get that $x=10z$ for some integer $z$ which must satisfy $z^2=11$. There is no such integer $z$, so necessarily $b=4$.

Since $b=4$, $y$ must be even. Therefore $y=2w$ and we get $25a+1=w^2$ and for an integer $w$ with $0<w<5$. Since $w^2\equiv1\pmod5$, we have $w=1$ or $w=4$. If $w=1$, then $x=22$, which is too small, so $w=4$ and $x=88$ is the only option. And a little calculation shows that $x=88$ indeed gives a solution: $88^2=7744$.

(There are many ways to go about this problem. For example, I never used the fact that $100a+b=11y^2$ implies $a+b\equiv0\pmod{11}$ and therefore $a+b=11$.)

We know as the number should be square $(1100a + 11b) \equiv 0 \mod 4$ or $(1100a + 11b) \equiv 1 \mod 4$. Therefore $b \in \text{{0,3,4,7,8}}$.
Furthermore we know that $11 \lvert (1100a + 11b)$, so $11 \lvert (100a+b)$. Therefore $(100a + b) \equiv 0 \mod 11$, so $(a+b) \equiv 0 \mod 11$, this leaves four cases which can be checked by hand $(8,3),(7,4),(4,7),(3,8)$.
I hope this helps.

• That works, and it's nice & compact, but it might be too condensed for some readers. You might like to explicitly mention that all squares are $\equiv$ 0 or 1 $\mod 4$; that $1100a+11b \equiv -b \mod 4$; and that $p | n^2 \implies p^2 | n^2$ so $11∣(1100a+11b) \implies11^2|(1100a+11b)$ – PM 2Ring Jul 14 '15 at 12:08