Outputting/finding first n numbers of Natural Binary Code:
import math
def binary_print(n):
m = int(math.ceil(math.log(n, 2)))
for i in range(n):
b = str(bin(i)[2:])
print((m - len(b)) * '0' + b)
My question is:
Do you know any other way to do this in Python? Maybe faster? Or shorter (less code)?