We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9dc7cd3 commit e1f83a0Copy full SHA for e1f83a0
18.3_FactorialCalculator/src/FactorialCalculator.java
@@ -5,11 +5,11 @@
5
public class FactorialCalculator
6
{
7
// recursive method factorial (assumes its parameter is >= 0)
8
- public long factorial (long number)
+ public static long factorial(long number)
9
10
- if (number <= 1)
11
- return 1; // test for base case
12
- else
+ if (number <= 1) // test for base case
+ return 1; // base cases: 0! = 1 and 1! = 1
+ else // recursion step
13
return number * factorial(number - 1);
14
} // end method factorial
15
0 commit comments