【Java开源代码栏目提醒】:网学会员--在 Java开源代码编辑为广大网友搜集整理了:JCCalc03.java绩等信息,祝愿广大网友取得需要的信息,参考学习。
package com.cownew.Char02;
import java.math.BigInteger;
import java.util.Random;
public class JCCalc03
{
public static void main(String[] args)
{
Random random = new Random();
for (int i = 0; i < 10000; i++)
{
int randInt = random.nextInt(10000);
System.out.println(calcFactor(BigInteger.valueOf(randInt)));
}
}
private static Big
Integer calcFactor(BigInteger value)
{
if (value.compareTo(Big
Integer.valueOf(0)) == 0)
{
return BigInteger.valueOf(1);
} else
{
BigInteger nPlusOne = value.subtract(BigInteger.valueOf(1));
return calcFactor(nPlusOne).multiply(value);
}
}
}