another fun question from my 5th grade



A,B,C,D are DIFFERENT counting numbers (1,2,3,4,5,6,7...)


ABCD doens't mean A times B times C times D, it means like 1,234 if A=1,B=2,C=3,D=4


Find A, B,C and D such that

ABCD times D=DCBA

represented like this:
ABCD
        D X
DCBA

remember, A,B,C,D are all different

Find A,B,C,D       
show all work and logic

Verified Answer :

Solutions 

The given question is a doable program.

Def pal():
    for a in range \((0,10):\)
        for b in range\((0,10):\)
            for c in range\((0,10):\)
                for d in range\((0,10):\)

   \(c^1 =int(d*d)\) %10)

                   \(y= (c*d + c^1)\) %10

                   \(c^2=int((c*d+c^1)/10)\)

                 \(z =(b*d +c^2)\) %10

                    \(c^3=int((b*d+c^2)/10)\)

                    \(w=(a*d+c^3)\) %10 

if (a!=b and a!=c and a!=d and b!=c and b!=d and c!=d and x==a and y==b and z==c and w==d ):
                       print("a = ", a)
                       print("b = ", b)
                       print("c = ", c)
                       print("d = ", d)

\(a= 1 b= 0 c=8 d=9\) 

Plug in the numbers to solve the problem.

The 'int' function is the same thing as floor.
The % symbol is the modulo operator


≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

In base 10 expanded form \(ABCD=A*1000+B*100+C*10+D\)
and \(DCBA=D*1000+C*100+B*10+A\) , where A,B,C,D are counting numbers. 

We are given \(ABCD*D=DCBA\)
Converting to decimal expanded forms we get 

\((A*1000+B*100+C*10+D)*D =D*1000+C*100+B*10+A\) 

Distributing the above equation

\(AD*1000+BD*100+CD*10+D^2 =D*1000+C*100+B*10+A\)

brute force solution works, but is best done by a computer not by hand. 

We could also try to use modular math. 

\(d^2 mod 10 = a\) 

\(cd+[d^2/10]mod10=b\) 

\(bd+[(cd+[d^2/10])/10]mod10=c\) 

\(ad+[(bd+[(cd+[d^2/10])]/10)/10]mod10=a))\) 

\(1089 * 9 = 9801\)

A can only be 1, because DA=D, and only 1 can get to that.
So B is 0, if not then the thousands place might not be D
In DCBA, the one's place is 1
D squared is 1, so D is 9 (because if D=1, then ABCDD=ABCD)
So C is 8
because it's the only one that's valid.
The final answer is A=1 B=0 C=8 D=9, and 1089
9=9801, so the statement hold true.