I am Computer Engineer, Write articles about python.

Full width home advertisement

Learning by Doing

Learn Python


Post Page Advertisement [Top]

 Recursion 

                                        is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.

Recursion occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics and computer science, where a function being defined is applied within its own definition. While this apparently defines an infinite number of instances (function values), it is often done in such a way that no infinite loop or infinite chain of references can occur.

 

Python allows functions to call itself. 


A Recursive Solution comprises of:
  • Base Part
                        It is the solution of the smallest version of the problem.
  • Inductive part
                        It is the Recursive part of the problem Which reduces complexity of problem.the solution is expressed in terms of a smaller version of itself. 
 

Recursive Solutions:

  •  Factorial:

     


No comments:

Post a Comment

Bottom Ad [Post Page]