Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Recursion in Python:-

If the function calls itself under function then it is called recursion.

every loop process has been implemented by recursion.


we can call the same function multiple times under function.


function xyz():

       xyz()


where xyz is the function that will be called under xyz() which is called recursion.


If we want to perform the addition of range from 1 to num then we can use this program using the recursion process.


def fun(num):

    

    if num ==0:

        return num

    else:

        return num+fun(num-1)



x=fun(5)

print(x)



Assignment of Recursion?


1)  WAP to calculate factorial using recursion?


2)  WAP to display Fibonacci series using recursion?

0 1 1 2 3 5 8 13 21 .......

3)  WAP to calculate the sum of even numbers and the odd numbers of 1 to 50 using recursion?













Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post