n的阶乘

阅读更多
public class Test {
public static void main(String[] args) {
BigInteger in = new BigInteger(String.valueOf(3));
BigInteger i = factorial(in);
System.out.println(i);
}

private static BigInteger factorial(BigInteger i) {
BigInteger value = new BigInteger("0");
BigInteger value1 = new BigInteger("1");
if(value1.compareTo(i) == 0 || value.compareTo(i) == 0){
return value1;
}else{
return i.multiply(factorial(i.subtract(value1)));
}

}
}

你可能感兴趣的:(java)