#K55392. Binary Palindrome Checker
Binary Palindrome Checker
Binary Palindrome Checker
Given a non-negative integer n, check whether its binary representation is a palindrome. In other words, if you write n in base 2 (ignoring the '0b' prefix), the resulting string should read the same forward and backward.
For example, when n = 9, its binary representation is 1001
which is a palindrome, so the output is True
. Conversely, if n = 10, the binary format is 1010
which is not the same read backwards, so the output is False
.
The binary representation of a number n is given by \( b(n) \), and the condition for a palindrome can be written in \( \LaTeX \) as:
\( b(n) = \text{reverse}(b(n)) \)
inputFormat
The input consists of a single non-negative integer n read from standard input.
Example:
9
outputFormat
Output a single line containing either True
if the binary representation of n is a palindrome or False
otherwise. The output should be printed to standard output.
Example:
True## sample
9
True