/**
 * 计算ln(N!)
 */
package algorithms;

/**
 * @author jersey
 *
 * @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)));
    }

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐