aboutsummaryrefslogtreecommitdiff
path: root/challenge-118/cristian-heredia/python/ch-1.py
blob: 118ba99782fceaa19dc8c21f11ebefa973e8dd5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''  
    TASK #1 › Binary Palindrome
    Submitted by: Mohammad S Anwar
    You are given a positive integer $N.

    Write a script to find out if the binary representation of the given integer is Palindrome. Print 1 if it is otherwise 0.

        Example
            Input: $N = 5
            Output: 1 as binary representation of 5 is 101 which is Palindrome.

            Input: $N = 4
            Output: 0 as binary representation of 4 is 100 which is NOT Palindrome.
    

'''   

N = 5

bits = f'{N:b}'
j = -1

for num in bits:
    if num != bits[j]:
        print("Output: 0")
        exit()
    j -= 1
print("Output: 1")