2진수에 해당하는 이진법은 연속적으로 2로 나눈 나머지를 역순으로 인쇄하여 얻습니다. 이 변환에 대한 재귀적 솔루션은 다음과 같습니다.
def tobin(x):
strbin=''
if x>1:
tobin(x//2)
print (x%2, end='')
num=int(input('enter a number'))
tobin(num)
To test the output, run above code enter a number25 11001 enter a number16 10000바디>