fastread homefastrread library fastread menu

Python : Convert Decimal to Binary Using Recursion

Tutorial by:Rizwan Abdullah      Date: 2016-06-16 01:51:45

❰ Previous Next ❱

Source Code

# Python program to convert decimal number into binary number using recursive function

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

# Take decimal number from user
dec = int(input("Enter an integer: "))


Enter an integer: 52

In this program, we convert decimal number entered by the user into binary using a recursive function. Decimal number is converted into binary by dividing the number successively by 2 and printing the remainder in reverse order.

❰ Previous Next ❱


Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website