We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0b9d411 commit 7a268a5Copy full SHA for 7a268a5
operator/factorial/CorrectFactorial.java
@@ -1,10 +1,8 @@
1
import java.math.BigInteger;
2
3
class CorrectFactorial {
4
- static final BigInteger two = new BigInteger("2");
5
-
6
public static BigInteger factorial(BigInteger n) {
7
- return n.compareTo(two) < 0 ? BigInteger.ONE
+ return n.compareTo(BigInteger.ONE) <= 0 ? BigInteger.ONE
8
: n.multiply(factorial(n.subtract(BigInteger.ONE)));
9
}
10
0 commit comments