This week's book giveaway is in the Android forum. We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line! See this thread for details.

A, B, C, D and E are 5 different single digit numbers. The number ABCDE times 4 will have a result of EDCBA. What digit numbers do A, B, C, D, and E represent?

Could any one tell me what is the logic to calculate this problem. Atleast direct others how to calculate this problem or tell the algorithm to solve it....

The Best way to predict your future is to create it - Every great individual common man

Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296

posted

0

Originally posted by Ankur Sharma: Could any one tell me what is the logic to calculate this problem. Atleast direct others how to calculate this problem or tell the algorithm to solve it....

21978 * 4 = 87912

I just used a simple loop from 10000 to 99999 and multiplied each number by 4, converted to a String, and checked to see if the String reversed was equal to the original number as a String.

Originally posted by Ankur Sharma: Could any one tell me what is the logic to calculate this problem. Atleast direct others how to calculate this problem or tell the algorithm to solve it....

You could look at it as an integer linear programming problem.

Find A,B,C,D,E such that.

A*10000 + B*1000 + C*100 + D*10 + E = 4*(E*10000 + D*1000 + C*100 + B*10 + A) - or - A*9996 + B*960 - C*300 - D*3990 - E*39999 = 0 A >= 0 A <= 9 B >= 0 B <= 9 C >= 0 C <= 9 D >= 0 D <= 9 E >= 0 E <= 9