i need to make a program that will identify the values of ABCDE that will result to EDCBA if you will multiply it with 4.

looks like this: ABCDE x 4 = EDCBA

i already have the values, it's 21978 x 4 = 87912

but i dont know how to make a program that can identify the values of ABCDE.

can you help me?.

Recommended Answers

All 4 Replies

Well there can be thousands of correct values here for the variables that you mention. For ex: ABCDE could be 4 and EDCBA could be 16, ABCDE could be 16 and EDCBA could be 64, etc, etc. So you cannot exactly get to the values that you mention.

Do you want to find out all possible values ?? I doubt.
Tell us more about your program.

no i dont want to find all the values :)

the values are static
A = 2
B = 1
C = 9
D = 7
E = 8

I assume this is an exam question, and your urgency in the PM tells me that you might actually be answering one.
I am not keen on giving answers straight up, more so in your case, because of some of my assumptions mentioned above.
I would give you the hint for this, if you are smart enough to take it, I suppose you deserve to get through.

You know how multiplication goes, since it is a single digit multiplication here (4) you can work your way this way,
Since, ABCDE * 4 = EDCBA,
A has to be ones digit of the result of E * 4.
B has to be the ones digit of the result of D * 4 + tens digit of E * 4

So to put this into prrogramming terms,
A = (E*4)%10
B = ( (D*4) + ((E*4)/10) ) % 10

I hope you are able to work your way now.

NOTE : Ignore my earlier post, as I completely misunderstood the problem.

Another approach might be to convert both the values ABCDE and 4*ABCDE to strings, reverse one of them, and use string comparison.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.