Find numbers which are palindrome in both their decimal and octal Representations

Objective: Given a range of integers, find all the numbers which are palindrome when they are represented in Decimal Value( base 10) and in Octal value(base 8).

Example :

Number : 373 (Decimal) and digits are palindrome.

Convert it into Octal which is 565 and that's also palindrome.


Solution is quite simple. Traverse through all the numbers in the given range and check if it palindrome, if yes, convert it into Octal and check for palindrome again.



1  2  3  4  5  6  7  11  171  444  515  565  636  1111  

Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

You may also like...

%d bloggers like this: