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?

$\endgroup$
13
$\begingroup$

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

4358
754  (+
------
11
 8
  9
   8
------
1998
$\endgroup$
  • 1
    $\begingroup$ So it's boils down to the simple addition routine without reversing the strings first ... Thanks :-) $\endgroup$ – Quixotic Mar 4 '11 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.