I have problem while reversing and checking palindrome for a number of specific base (other than 10). For example:- let's take 87. The Palindrome number is found as follows:
87+78= 165+ 561 = 726 + 627= 1353 + 3531 = Palindrome !
This method works fine for a number with base 10. But how to do this for another number with different base. Just like, 1211 with base 3 forms Palindrome 112211 and 3112 with base 4 forms Palindrome 233332 . I used these results to test my code. But the output doesn't match. Please guide me and share your precious knowledge, I shall be glad and thankful to you :)
Mathematically, arithmetic in different bases is not too complicated. The only thing you have to change is your definition of "carrying" for example, $54_9 + 76_9 = \underline{12_9}$ $\underline{10_9}$ which is then equal to $141_9$. Notice how instead of carrying numbers once they reached $10$, we carry after they reach $9$.
Here's an example. Let's take $56_7$.
$56_7 + 65_7 = \underline{11_7}$ $\underline{11_7} = 154_7$
$154_7 + 451_7 = \underline{5_7}$ $\underline{10_7}$ $\underline{5_7} = 635_7$
$635_7 + 536_7 = \underline{11_7}$ $\underline{6_7}$ $\underline{11_7} = 1504_7$
$1504_7 + 4051_7 = \underline{5_7}$ $\underline{5_7}$ $\underline{5_7}$ $\underline{5_7} = 5555_7$
And there's your palindrome number!