package com.swift; public class Digui_Return { public static void main(String[] args) { /* * 递归算法题2 第1个人10,第2个比第1个人大2岁,依次递推,请用递归方式计算出第8个人多大? */ int num = 8; System.out.println("The 8th person's age is "+old(num)); } public static int old(int num) { if (num == 1) { return 10; } else { return 2 + old(--num); } } }