We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n=int(input("Enter a number: "))
a=[]
while(n>0):
dig=n%2
a.append(dig)
n=n//2
a.reverse()
print("Binary Equivalent is: ")
for i in a:
print(i,end=" ")
Consecutive 1's in Binary Numbers
You are viewing a single comment's thread. Return to all comments →
n=int(input("Enter a number: ")) a=[] while(n>0): dig=n%2 a.append(dig) n=n//2 a.reverse() print("Binary Equivalent is: ") for i in a: print(i,end=" ")