update from Atlas

This commit is contained in:
Luciano Ramalho 2014-12-30 16:07:42 -02:00
parent 0b9d411f5c
commit 7a268a5b43

View File

@ -1,10 +1,8 @@
import java.math.BigInteger;
class CorrectFactorial {
static final BigInteger two = new BigInteger("2");
public static BigInteger factorial(BigInteger n) {
return n.compareTo(two) < 0 ? BigInteger.ONE
return n.compareTo(BigInteger.ONE) <= 0 ? BigInteger.ONE
: n.multiply(factorial(n.subtract(BigInteger.ONE)));
}