【java】求大数的阶乘

来源:互联网 发布:淘宝宝贝图片复制 编辑:程序博客网 时间:2024/05/17 22:00
import java.math.BigInteger;public class test {final static BigInteger c = new BigInteger("1");public static void main(String[] args){BigInteger b = new BigInteger("100");System.out.println("The result of 100! is "+test(b));}    public static BigInteger test(BigInteger n){        if(n.equals(c))    return c;    else{    return n.multiply(test(n.subtract(c)));    }    }}

0 0
原创粉丝点击