Recursive function
What is recursive function ? A recursive function is the function that calls itself during execution of program. Every recursive solution has two major cases, which are fallows: Base case , in which the problem is simple enough to solve directly without making any further calls to the same function. Recursive case , in which first the problem at hand divided into simpler sub-part. Second, the function calls itself but sub-parts of the problem obtained in the first stem. Third, the result is obtained by combining the solutions of simpler sub- part. Thus we see that recursion utilized divide and conquer technique of problem solving. Divide and conquer technique is a method of solving a given problem by dividing it into two or more smaller instances. Now for understand the recursive function let us see an example of calculating factorial of a number. The factorial of a number id n!= n x (n-1)! Now , 5!= 5 x 4 x 3 x 2 x1 =120 This can be written as: 5!= 5 x 4! 4!= 4 x 3! 3!= 3 X 2