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

Respuesta :

Solutions 

The given question is a doable program.

Def pal():
    for a in range [tex](0,10):[/tex]
        for b in range[tex](0,10):[/tex]
            for c in range[tex](0,10):[/tex]
                for d in range[tex](0,10):[/tex]

   [tex]c^1 =int(d*d) [/tex] %10)

                   [tex] y= (c*d + c^1)[/tex] %10

                   [tex] c^2=int((c*d+c^1)/10)[/tex]

                 [tex] z =(b*d +c^2)[/tex] %10

                    [tex]c^3=int((b*d+c^2)/10)[/tex]

                    [tex]w=(a*d+c^3)[/tex] %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)

[tex]a= 1 b= 0 c=8 d=9[/tex] 

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 [tex]ABCD=A*1000+B*100+C*10+D [/tex]
and [tex]DCBA=D*1000+C*100+B*10+A[/tex] , where A,B,C,D are counting numbers. 

We are given [tex]ABCD*D=DCBA [/tex]
Converting to decimal expanded forms we get 

[tex](A*1000+B*100+C*10+D)*D =D*1000+C*100+B*10+A [/tex] 

Distributing the above equation

[tex]AD*1000+BD*100+CD*10+D^2 =D*1000+C*100+B*10+A [/tex]

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

We could also try to use modular math. 

[tex]d^2 mod 10 = a[/tex] 

[tex]cd+[d^2/10]mod10=b[/tex] 

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

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

[tex]1089 * 9 = 9801[/tex]
A can only be 1, because D*A=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 ABCD*D=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.