Java 递归求阶乘
package cn.geekeryi; public class DiGui { public static void main(String[] args) { System.out.println(factorial(5)); } static long factorial(int n){ if (n==1){ return 1; }else { return n*factorial(n-1); } } }
Java 递归求阶乘
package cn.geekeryi; public class DiGui { public static void main(String[] args) { System.out.println(factorial(5)); } static long factorial(int n){ if (n==1){ return 1; }else { return n*factorial(n-1); } } }