递归的必要条件:
1. 将原问题划分成其子问题,注意:子问题必须要与原问题的解法相同
2. 递归出口
public class TestMethod {
    //通过递归求n的阶乘
    public static int factor(int n) {
        if (n == 1) {
            return 1;
        }
        return n * factor(n - 1);
    }
    public static void main(String[] args) {
        int n=5;
        int ret=factor(n);
        System.out.println("ret="+ret);
    }
}










