题目链接:点击这里
import java.math.BigInteger; //大整数类
import java.math.BigDecimal; //大浮点数类
import java.util.*; //要用java.util包中的类Scanner
//必须是public class Main提交,并且不能带包名
public class Main {
public static void main(String[] args) {
//创建输入流对象input
Scanner input = new Scanner(System.in);
//多组数据,hasNext()判断是否输入了内容
while(input.hasNext()) {
//使用输入流对象input调用nextInt()方法输入一个整数到n中
int n = input.nextInt();
//基本常量
//BigInteger.ONE = 1
//BigInteger.TEN = 10
//BigInteger.ZERO = 0
BigInteger ans = BigInteger.ONE;
for(int i = 1; i <= n; i++)
ans = ans.multiply(BigInteger.valueOf(i));
System.out.println(ans);
}
}
}
1、public BigInteger multiply(BigInteger val)
Parameters:
- val − Value to be multiplied by this BigInteger.
Return Value:
- This method returns a BigInteger object whose value is this * val.
Exception:
- NA
2、public static BigInteger valueOf(long val)
参数:
- val - 该BigInteger返回的值
返回值:
- 此方法返回一个BigInteger,使用指定的值。
异常:
- NA