N! Java大数 水过

版权声明:欢迎转载,如果转载,请注明转载地址,谢谢! https://blog.csdn.net/qq_40763929/article/details/84027444

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);
		}

	}

	

}

猜你喜欢

转载自blog.csdn.net/qq_40763929/article/details/84027444
今日推荐