MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / factorial

Function factorial

Recursion/Code/factorials.cpp:7–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5using namespace std;
6
7long long int factorial(int n) { //Base Case
8
9 if (n==0 || n==1){
10 return 1;
11 }
12
13 else{
14 //return n * factorial(n-1) one way
15 //other way
16
17 int recResult = factorial(n-1); // Recursive Call
18 int result = n*recResult; // Small Calculation
19 return result;
20 }
21}
22
23int main(){
24

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected