InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Palindromic Binary Representation


Problem Description

Given an integer A find the Ath number whose binary representation is a palindrome.

NOTE:

  • Consider the 1st number whose binary representation is palindrome as 1, instead of 0
  • Do not consider the leading zeros, while considering the binary representation.



Problem Constraints

1 <= A <= 2104



Input Format

First and only argument is an integer A.



Output Format

Return an integer denoting the Ath number whose binary representation is a palindrome.



Example Input

Input 1:

 A = 1

Input 1:

 A = 9



Example Output

Output 1:

 1

Output 2:

 27



Example Explanation*

Explanation 1:

 1st Number whose binary representation is palindrome is 1

Explanation 2

 9th Number whose binary representation is palindrome is 27 (11011)



NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Palindromic Binary Representation on Interview Code Editor
Sign Up
to access hints and editorial solutions for Palindromic Binary Representation
Asked In:

Discussion


Loading...
Click here to start solving coding interview questions