C Online Compiler
Example: C program to find factorial of a number using recursion
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to find factorial of a number using recursion #include <stdio.h> // @recursive function to find the factorial long int RecursiveFacto(int fact_number) { if (fact_number >= 1) return fact_number * RecursiveFacto(fact_number - 1); else return 1; } // @driver function to call & find // @factorial of a number using recursion int main() { int fact_number = 0; printf("Enter a positive integer number: "); scanf("%d", &fact_number); // It will call the RecursiveFacto() function printf("\nFactorial of %d is: %ld\n", fact_number, RecursiveFacto(fact_number)); return 0; }
5
Output
Clear
ADVERTISEMENTS