本帖最后由 Samples、懂么 于 2016-4-7 13:53 编辑 package org.tools.hive;
import java.math.BigInteger;
public class Test {
public static void main(String[] args) {
int end = 30;
BigInteger sum = new BigInteger("0");
for( int i=1; i<end; i++ ){
BigInteger factorial = null;
for( int j=i; j>0; j-- ){
if( factorial == null ){
factorial = new BigInteger(j + "");
System.out.println("第 " + j + " 轮 ");
}else{
String output = "过程 : " + factorial.toString() + " * " + j + " = ";
factorial = factorial.multiply(new BigInteger(j + ""));
System.out.println(output + factorial.toString());
}
}
sum = sum.add(factorial);
}
System.out.println("最终结果 : " + sum.toString());
}
}
|