# Keadara's algorithm to generate binary sequence with n bits

# reading no: of bits from user
n = int(input("Enter no: of bits = "))

#starting with all zeros
seq=[0]*n
print(seq)

# copying initial sequence to start changing bit values
c=seq

#condition to repeat till all values are 1
while c!=[1]*n:
    for i in range(len(seq)):
        #looking for first 0 and changing it's value to 1
        if seq[i]==0:
            c[i]=1
            # leaving the next values unchanged
            break
        else :
            # changing values before encountering first 0
            c[i]=0
    print(c)
