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

Method fact

Recursion/Code/factorials.java:5–17  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

3 {
4
5 static int fact(int n)
6 {
7 if(n==0 || n==1) // base condition;
8 return 1;
9
10 int recResult = fact(n-1);
11 int smallCal = n*recResult;
12
13 return smallCal;
14
15
16 //return (n == 1 || n == 0) ? 1 : n * fact(n - 1); --One liner using ternary operator.
17 }
18
19 // Driver Code
20 public static void main(String args[])

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected