4
$\begingroup$

Given two natural numbers I am supposed to reverse each of them and then sum them up and reverse the sum to get the final answer.

For example if the numbers are $4358$ and $754$ then the answer should be $1998$

I always thought that there should be a mathematical trick avoid brute force (i.e reversing each numbers and summing them up and reverse the sum to get the final answer).I heard "double reverse is no reverse" but never really get the trick myself.Could anybody help?

1 Answers 1

13

Line the numbers up flush left. When you carry a digit, carry to the right. Something like

4358 754  (+ ------ 11  8   9    8 ------ 1998 
  • 1
    So it's boils down to the simple addition routine without reversing the strings first ... Thanks :-)2011-03-04