For the following I have to convert an int to a binary string. I have a few constraints, I can't change the first two lines and moreover, I have to return a binary representation for 10^a, where a is the input int. I tried the following, but it doesn't work the way it should. Also, the solution needs to be recursive. Please help someone.
{int} -> {str} return a binary string for 10^a
def converttobin(a: int) -> str:
if a == 1:
return "0b1010"
else:
return converttobin(10^a//2) + str(a % 2)