N!
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 86809 Accepted Submission(s): 25529
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
1 2 3
Sample Output
1 2 6做法:以前有写过自己实现的java大数相乘,这里直接用他的类BigInteger。代码:public class Nplusplus1042 { Nplusplus1042() { int n = 10000; BigInteger result = new BigInteger("1"); for (int i = 2; i <= n; i ++) { BigInteger b = new BigInteger(i + ""); result = result.multiply(b); } System.out.print(result +""); } public static void main(final String[] args) throws Exception { Nplusplus1042 n = new Nplusplus1042(); } }