Hdu--N!--1042

来源:互联网 发布:dnf刷称号软件 编辑:程序博客网 时间:2024/05/22 12:37

N!

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 43577    Accepted Submission(s): 12239


Problem Description
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
 

Input
One N in one line, process to the end of file.
 

Output
For each N, output N! in one line.
 

Sample Input
123
 

Sample Output
126
 
import java.math.BigInteger;import java.util.Scanner;public class dashu {public static void main(String[] args) {Scanner input = new Scanner(System.in);while(input.hasNext()){BigInteger n = input.nextBigInteger();BigInteger sum = BigInteger.valueOf(1);for(BigInteger i=BigInteger.valueOf(1); ; i=i.add(BigInteger.valueOf(1))){if(i.compareTo(n)>0){break;}sum = sum.multiply(i);}System.out.println(sum.toString());}}}

原创粉丝点击