Recursion function

Recursion function is a function that call itself up to the certain number of times or till the condition is not satisfied. In recursion function we cannot use any loop only if condition is used.

Example 1: WAP to find factorial using recursion function.


int fact( int n );

int main()
    int n, r;
    printf("Enter number: ");
    r = fact(n); //function call
    printf("Factorial = %d",r);

int fact(int n)
    static int a;
        return 1;
        a = n * fact(n-1);
    return a;
Enter number: 5
Factorial = 120.