Recursive function is a function which contains a call to itself.

Why recursive function

Recursive function allows you to divide your complex problem into identical single simple cases which can handle easily.

Warning of using recursive function

Recursive function must have at least one exit condition that can be satisfied. Otherwise, the recursive function will call itself repeatly until the runtime stack overflows.

The recursive function to calculate factorial
# include<stdio.h>
int factorial(unsigned int number)
    if(number <= 1)
        return 1;
    return number * factorial(number - 1);
void main()
    int x = 5;
    printf("factorial of %d is %d",x,factorial(x));