Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

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

Objec­tive: Given a range of inte­gers, find all the num­bers which are palin­drome when they are rep­re­sented in Dec­i­mal Value( base 10) and in Octal value(base 8).

Exam­ple :

Number : 373 (Decimal) and digits are palindrome.

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

Approach:

Solu­tion is quite sim­ple. Tra­verse through all the num­bers in the given range and check if it palin­drome, if yes, con­vert it into Octal and check for palin­drome again.

Code:   


Out­put:

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

You may also like...