N! Java大数 水过

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


 

1 2 3

Sample Output


 

1 2 6

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

public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		
		Scanner cin = new Scanner(System.in);
		while (cin.hasNext())
		{
			int n = cin.nextInt();
			BigInteger sum = new BigInteger("1") ;
			int i=1;
			while (i<=n)
			{
				sum = sum.multiply(BigInteger.valueOf(i));
				i++;
			}
			System.out.println(sum);
		}

	}

	

}
原文地址:https://www.cnblogs.com/Romantic-Chopin/p/12451210.html