1057 N的阶乘

时间:2021-11-11 07:39:59

1057 N的阶乘

基准时间限制:1 秒 空间限制:131072 KB

输入N求N的阶乘的准确值。

Input

输入N(1 <= N <= 10000)

Output

输出N的阶乘

Input示例

5

Output示例

120

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
static BigInteger ans(BigInteger a,int b){
BigInteger anss=BigInteger.ONE;
for(int i=1;i<=b;i++)
anss=anss.multiply(new BigInteger(i+""));
return anss; } public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
BigInteger a=sc.nextBigInteger();
int b=Integer.parseInt(a+"");
System.out.println(ans(a,b)); } sc.close(); } }