Java计算ln(N!)

来源:互联网 发布:tensorflow r语言 编辑:程序博客网 时间:2024/06/05 20:18
/** * 计算ln(N!) */package algorithms;/** * @author yulele * * @time 2017年5月11日 上午10:25:50 */public class LogarithmOfFactorial {    /**     * 递归法求阶乘     */    private static long fac(int n) {        if(n==0||n==1) return 1;        return n * fac(n-1);    }    public static void main(String[] args) {        System.out.println(fac(10));        System.out.println(Math.log(fac(10)));    }}
0 0
原创粉丝点击