标签:递归
|--代码
package com.collection; public class Demo2 { public static void main(String[] args) { /** * 求5的阶乘 */ //方案1:普通循环 int i = 1; for(int x = 1; x <= 5; x++) { i= i*x; } //System.out.println(i); //方案2:递归 System.out.println(jc(5)); } public static int jc(int i) { if(i==1) return 1; else return i*jc(i-1); } }
标签:递归
原文地址:http://blog.csdn.net/hubiao_0618/article/details/38855727