top of page

Python Program to Convert Decimal to Binary using recursive function

  • Writer: Rajesh Singh
    Rajesh Singh
  • Oct 12, 2021
  • 1 min read


def decitobin(n):

if n > 1:

decitobin(n // 2)

print(n % 2,end='')

num = int(input("Enter any decimal number: "))

decitobin(num)


Output:

Enter any decimal number: 42

>

101010>




Recent Posts

See All

Comments


bottom of page