public static synchronized BigInteger bigNumber(int num){//利用BigInteger类计算阶乘
ArrayList list = new ArrayList();//创建集合数组
list.add(BigInteger.valueOf(1));//往数组里添加一个数值
for (int i = list.size(); i <= num; i++) {
BigInteger lastfact = (BigInteger) list.get(i - 1);//获得第一个元素
BigInteger nextfact = lastfact.multiply(BigInteger.valueOf(i));//获得下一个数组
list.add(nextfact);
}
return (BigInteger) list.get(num);//返回数组中的下标为num的值
}