标签:描述 代码 static size 使用 line 过多 多次 ima
1 package com.duan.method; 2 3 public class Demo06 { 4 //递归思想:基数小可以使用,如果调用自身过多,反而会影响机器性能。这是个不够优秀的算法 5 public static void main(String[] args) { 6 7 System.out.println(f(5));//120 8 System.out.println(f(4));//24 9 } 10 11 //阶乘5! 5*4*3*2*1 12 public static int f(int n) { 13 if (n == 1) { 14 return 1; 15 } else { 16 return n * f(n - 1); 17 } 18 } 19 }
标签:描述 代码 static size 使用 line 过多 多次 ima
原文地址:https://www.cnblogs.com/duanfu/p/12222316.html