I'm writing a program in C++ where you enter a number and it lists all the bases in which that number is a palindrome. What I'm stuck on is what to do for higher bases though, for example:
Converting 170 to base 90,
170 % 90 = 1 R 80
1 % 90 = 0 R 1
So since the Remainder 80 is above the letter Z which would be 35, what do you do?
I cant seem to find any converters that go up to bases this high to test out what should happen, so if anyone could point me to one that would be really helpful too.
Since the program does not actually have to display the converted number to find a palindrome, it can internally represent each "digit" as an
int
(in an array) which is 32 or 64 bits. This will naturally be fast since such matches are presumably uncommon if not rare.Once a palindrome match is found, then outputting it can be done anyway you want. Maybe just print a list of
int
values. Look at the history of hexadecimal: in the early days there were all kinds of unusual schemes, some of which used special characters.Up to base 64 there are some common standards, but beyond that, you are in largely uncharted territory.