Find all 4 digits numbers that $ABCD=(CD)^2$

138 Views Asked by At

Please help me to solve following problem:

Find all 4 digits numbers such that $ABCD=(CD)^2$.(any of $A,B,C,D$ is a digit!)

I know one of solutions is $5776=(76)^2$.

3

There are 3 best solutions below

0
On

If you allow leading zeros, there are three more. $D$ must be $0,1,5,6$. You can then just try them all-there are only $40$ possibilities. As $0,1$ don't carry, in both cases we must have $C=0$. For $5$ it has to be $2$, giving $00,01,25,76$

1
On

We need $D^2\equiv D\pmod{10}$ hence $D(D-1)$ must be a multiple of $10$. This implies that $D\in\{0,1,5,6\}$.

Next, the tens digit of $(CD)^2=(10\cdot C+D)^2=100\cdot C^2+20\cdot C\cdot D+D^2$ is determined by the ones digit of $2\cdot C\cdot D$ and the tens digit of $D^2$.

  • For $D=0$ we need $2\cdot 0\cdot C\equiv C\pmod {10}$, so $C=0$.
  • For $D=1$ we need $2\cdot 1\cdot C\equiv C\pmod {10}$, so $C=0$.
  • For $D=5$ we need $2\cdot 5\cdot C+2\equiv C\pmod {10}$, so $C=2$
  • For $D=6$ we need $2\cdot 6\cdot C+3\equiv C\pmod {10}$, so $C=7$

Thus the full list of answers is $$00^2=0000\quad 01^2=0001\quad 25^2=0625\quad 76^2=5776 $$ and possibly you won't count the first three as valid.

0
On

If a programmatic solution (Python 2.7) is acceptable, then:

for n in range(0,100):
    if (n*n)%100 == n:
        print "%04d"%(n*n)

Gives:

0000
0001
0625
5776