Skip to content

Commit e1f83a0

Browse files
committed
New stuff from ch18 and exercise 17
1 parent 9dc7cd3 commit e1f83a0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

18.3_FactorialCalculator/src/FactorialCalculator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
public class FactorialCalculator
66
{
77
// recursive method factorial (assumes its parameter is >= 0)
8-
public long factorial (long number)
8+
public static long factorial(long number)
99
{
10-
if (number <= 1)
11-
return 1; // test for base case
12-
else
10+
if (number <= 1) // test for base case
11+
return 1; // base cases: 0! = 1 and 1! = 1
12+
else // recursion step
1313
return number * factorial(number - 1);
1414
} // end method factorial
1515

0 commit comments

Comments
 (0)