//递归,累计+1,非尾递归 public static int cap(int n) { if (n == 1) { return 1; } return cap((n - 1)) + 1; } //递归,累计+1,尾递归 public static int capTail(int n, int m) { if (n == 1) { return m; } m++; return capTail((n - 1), m); } //阶乘,非尾递归 public static int factorial(int n) { if (n == 1) { return 1; } return n * factorial((n - 1)); } //阶乘,尾递归 public static int factorialTail(int n, int m) { if (n == 1) { return n; } m *= n; return factorialTail((n - 1), m); }