Given an integer ‘n’, write a Python function that returns true if binary representation of x is palindrome else return false.
Input : n = 9 Output : True Binary representation of n=9 is 1001 which is palindrome as well. Input : n = 10 Output : False Binary representation of n=10 is 1010 which is not palindrome.
We have existing solution for this problem please refer Check if binary representation of a number is palindrome link. We can solve this problem in python very quickly. Approach is very simple,
- Convert given number into it’s binary representation using bin(num) function.
- Now reverse binary representation string of number and compare it with original binary represented string, if both are equal that means binary representation of number is pallindrome else not.
Note : We can use other approach of checking a string is palindrome or not.
- Check if actual binary representation of a number is palindrome
- Check if Inorder traversal of a Binary Tree is palindrome or not
- Python Map | Length of the Longest Consecutive 1's in Binary Representation of a given integer
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Python program to check if a string is palindrome or not
- Python program to check whether the string is Symmetrical or Palindrome
- Python program to check if given string is vowel Palindrome
- Python program to check if number is palindrome (one-liner)
- Decimal representation of given binary string is divisible by 10 or not
- Decimal representation of given binary string is divisible by 20 or not
- C program to count zeros and ones in binary representation of a number
- Python | Check if there are K consecutive 1's in a binary number
- Check if Decimal representation of an Octal number is divisible by 7
- Python Dictionary | Check if binary representations of two numbers are anagram
- Binary String of given length that without a palindrome of size 3
- Check if sum of any subarray is Palindrome or not
- Check if the sum of digits of N is palindrome
- Check if a number is Palindrome in PL/SQL
- Check if a given string is Even-Odd Palindrome or not
- Check if a number is Palindrome
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.