programming-examples/python/_Basics/Python Program to Convert Decimal to Binary Using Recursion.py

11 lines
231 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
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)