题目如下:
代码如下:
package huawei; import java.util.ArrayList; public final class Demo { public static String calcNN(int n) { ArrayList<Integer> a = new ArrayList<Integer>(); a.add(1); int carry = 0; for(int i = 2;i<=n;i++){ carry = 0; for(int j=0;j<a.size();j++){ int temp = a.get(j)*i+carry; a.set(j, temp%10); carry = temp/10; } while(carry>0){ a.add(carry%10); carry /=10; } } String result = ""; for(int i = a.size()-1;i>=0;i--){ result+=a.get(i); } return result; } }
原文:http://blog.csdn.net/yayun0516/article/details/50492478