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.
void recursion() { recursion(); /* function calls itself */ } int main() { recursion(); }
#include <stdio.h
unsigned long long int factorial(unsigned int i) { if(i <= 1) { return 1; } return i * factorial(i - 1); } int main() { int i = 12; printf("Factorial of %d is %d\n", i, factorial(i)); return 0; }
When the above code is compiled and executed, it produces the following result −
Factorial of 12 is 479001600