Given a non-negative integer n, write a function to_binary/ToBinary which returns that number in a binary format. to_binary(1) # should return 1 to_binary(5) # should return 101 to_binary(11) # should return 1011
def to_binary(n): if n < 2: return str(n) else: return to_binary(n // 2) + str(n % 2)