python 十进制数转二进制数

 

def convertToBinary(n):
   """Function to print binary number
   for the input decimal using recursion"""
   if n > 1:
       convertToBinary(n//2)
   print(n % 2,end = '')

# decimal number
dec = 34

convertToBinary(dec)

 

posted @ 2018-11-19 19:58  anobscureretreat  阅读(1356)  评论(0编辑  收藏  举报