注解
1、Java大数,求阶乘即可。
代码
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextBigInteger()){
BigInteger bi = sc.nextBigInteger();
BigInteger re = BigInteger.ONE;
BigInteger temp = BigInteger.ONE;
int cmp = temp.compareTo(bi);
while(cmp<=0){
re = re.multiply(temp);
temp = temp.add(BigInteger.ONE);
cmp = temp.compareTo(bi);
}
System.out.println(re);
}
}
}