MCPcopy Create free account
hub / github.com/CodeWithHarry/The-Ultimate-C-Programming-Course / factorial

Function factorial

Chapter 5/05_recursion.c:10–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 // = 1 x 2 X 3 X .... X n-1
9
10int factorial(int n){
11 if(n == 1 || n == 0){ // Base condition
12 return 1;
13 }
14 // Factorial(n) = Factorial(n-1) X n
15 return n * factorial(n-1);
16}
17
18int main(){
19 int a = 6;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected