Sunday, 12 March 2017

Function to Convert Decimal to Binary Using Recursion

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

No comments:

Post a Comment