1042 N!

 

 

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
 

 

Author
JGShining(极光炫影)

 

 

 

 

 

/**
 * Presentation:
 *
 * Author: Vincent
 * Time:Sep 20, 2010 8:58:31 PM
 * ZheJiang University
 */
package HDOJ;

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

//public class hdoj1042 {
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		while(in.hasNextInt())
		{
		BigInteger n;
		int temp = in.nextInt();
		if(0 == temp)
			System.out.println("1");
		else
		{
			n = BigInteger.valueOf(1);
			for(int i =1; i<=temp ; i++)
			{
				n = n.multiply(BigInteger.valueOf(i));
			} 
			System.out.println(n.toString());
		}
		}
	}

}

posted @ 2010-09-20 21:18  にんじゃ  阅读(536)  评论(0)    收藏  举报