C Program To Find Factorial using Recursion
Learn How To Find Factorial using Recursion in C Programming Language. It is important that we should know How A For Loop Works before getting further with the C Program.
What is a Factorial of a Number?
A Factorial for a Non-Negative Integer is the Product of all the Positive Integers Less than or Equal to that Number.
Example
4! = 4 * 3 * 2 * 1
Also Read: C Program To Find Factorial of a Number using For Loop
Note: This C Program to Find Factorial of a Number using Recursion method has been compiled with GNU GCC Compiler and developed with gEdit Editor and Terminal in Linux Ubuntu Operating System.
C Program To Find Factorial using Recursion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include<stdio.h> int factorial(int x); int main() { int num, res; printf("\nEnter a Number:\t"); scanf("%d", &num); res = factorial(num); if(res == num) { printf("\nFactorial of %d is %d\n", num, res); } else { printf("\nFactorial of %d is %d\n", num, res); } return 0; } int factorial(int x) { if(x == 1) return x; else return (x*factorial(x - 1)); } |
Also Read: C Program To Find Sum of Digits of Number using Recursion
Output

Also Read: C Program To Print Fibonacci Series using Recursion
If you have any compilation errors or doubts in this C Program To Find Factorial of a Number using Recursion, let us know about in the Comment Section below.