第1个人10,第2个比第1个人大2岁,依次递推,请用递归方式计算出第8个人多大?
public class Test{ public static void main(String[] args) { System.out.println(computeAge(8)); } private static int computeAge(int i) { if(i==1){ return 10; } return computeAge(i-1)+2; } }
public class Test{ public static void main(String[] args) { System.out.println(computeAge(8)); } private static int computeAge(int i) { if(i==1){ return 10; } return computeAge(i-1)+2; } }