Reverse bits
Problem to find the 8 bit binary value and return the decimal of that reversed binary value.
if n=2--> binary value = "10" convert 8 bit = "00000010" reverse binary = "01000000" decimal value of reverse binary value = 64.
Example-1:
Input : n = 2 Output : 64
Example-2:
Input : n = 3 Output : 192
Solution
n = 2 n = bin(n) n = n[2:] n = n[::-1] a = 8-len(n) b = n + ("0"*a) b = b[::-1] d = 0 for i in range(0,len(b)): if(b[i] == "1"): d += 2**i print(d)
Output
64