JAVA求N!

import java.math.BigInteger;
import java.util.Scanner;

public class theFactor_of_N {

    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int t=n;
        BigInteger res=new BigInteger("1");
        for(int i=2;i<=n;i++ ){
            String tp=""+i;
            BigInteger res1=new BigInteger(tp);
            res=res.multiply(res1);

        }
        System.out.println(res);
        in.close();//用了vscode才知道这里要关上QAQ
    }

}

 

全部评论

相关推荐

ohs的小木屋:比不少实习待遇高了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务