Home » Blog » Recursive Function In Python

Recursive Function In Python

Write a recursive function that takes x value as an input parameter and print x-digit strictly in increasing number. [i.e. x = 6 than output 67891011].

def printdemo(x,count):
    if(count<=0):
        return
    else:
        print(x,end='')
        x=x+1
        count=count-1
        printdemo(x,count)
        
        
x=int(input("Enter Number "))
printdemo(x,x)
  • OutPut
Enter Number 7
78910111213

 

Tags:

Leave a Reply

Your email address will not be published.