# Recursion

**Recursion** is defined as a process which calls itself directly or indirectly and the corresponding function is called a recursive function. It is based on the principle of mathematical induction. In recursion we solve a bigger problem by solving the smaller sub problems A function calls itself to solve its sub problem.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692753414549/bc98eb73-de6f-431d-97f3-b7137185bfc2.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692645282431/a68e4356-e7a6-4c75-b1fc-f4d7c0d32b0d.png align="center")

### Questions

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692645943874/d367c953-3884-4ac8-9d11-a0581c7917a0.png align="center")

We assume that the function is working for f(n-1) {Just like in PMI, we have assumed that the function is working for Kth term} and now we have to just think what should we do after getting f(n-1) to get the final answer (Self work), As in PMI we have proof that the function is working for k=1, Here we have to similarly find a base case (halting condition) for n=1.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692647391192/e90420f3-c009-4cf2-8f27-c7b58eb9f2cc.png align="center")

whenever a method is called a stack frame is built in the call stack, Whenever a function is called its line number is recorded And after completing the function the stack frame of the running function is removed and the execution of. the caller function continues.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692651252736/7f63a849-fee2-4b2f-874a-69f346e85e39.png align="center")

### Thank You For Reading.

### Keep Coding.
