排序-递归

排序-递归,第1张

排序-递归
public class TestFactorial {
    public static void main(String[] args) {

//求N的阶乘
 long result=factorial(5);
        System.out.println(result);


    }

    private static long factorial(int n) {
        if(n==1){

            return 1;
        }
        return n*factorial(n-1);
    }
//    求n的阶乘
}

D:javajdkjdk-14.0.2binjava.exe "-javaagent:D:ideaIC-2021.2.2IDEAIntelliJ IDEA 2020.1.1libidea_rt.jar=49644:D:ideaIC-2021.2.2IDEAIntelliJ IDEA 2020.1.1bin" -Dfile.encoding=UTF-8 -classpath E:ideaProjectitcastoutproductiondata_structure TestFactorial
120

Process finished with exit code 0
 

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5609304.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存