Write a recursive function that accepts a decimal integer and display its binary equivalent.

Source Code

def decToBinary(num):
    if (num == 0):
        return

    decToBinary(num // 2)
    print(num % 2,end="")


#calling the function
number = 45
print("Decimal equivalent of",number,"is ",end="")
decToBinary(number)

Output

Decimal equivalent of 45 is 101101