JAVA中自带BigInteger类,用类下的multiply函数就能解决
import java.math.BigInteger;
import java.util.Scanner;
public class text {
public static void main(String[] args) {
int n=0;
Scanner s = new Scanner(System.in);
while(s.hasNext()){
n =s.nextInt();
BigInteger b = new BigInteger("1");
for(int i=2;i<=n;i++){
BigInteger c = new BigInteger(String.valueOf(i));
b = b.multiply(c);
}
System.out.println(b);
}
s.close();
}
}