+ 2
You need to implement a recursive function to print binary strings of length n bits in ascending order .
like if we give input 2 then output will be: 00 01 10 11 in different lines
4 Respostas
+ 2
thanks
+ 2
may be this also correct-
def PrintBinary():
n=int(input())
if n>=1:
k=2**n
for i in range(k):
print(format(i,'0'+str(n)+'b'))
PrintBinary()
+ 1
You mean like this? Sorry that i didnt use recursion but i dont think that recursion is appropiate here...
https://code.sololearn.com/cpT8LRWKzCSP/?ref=app
0
thank you