+ 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

31st Dec 2017, 7:54 AM
Nikhil Kohli
Nikhil Kohli - avatar
4 Respuestas
+ 2
thanks
31st Dec 2017, 10:30 AM
Nikhil Kohli
Nikhil Kohli - avatar
+ 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()
31st Dec 2017, 10:35 AM
Nikhil Kohli
Nikhil Kohli - avatar
+ 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
31st Dec 2017, 8:39 AM
romangraef
0
thank you
16th Jul 2023, 7:09 AM
JP joseph
JP joseph - avatar