- public static void main(String[] args) {
- test1();
- }
-
- public static void test1(){
- System.out.println("----test1----");
- test1();
- }
-
- public static void test2(){
- System.out.println("----test2----");
- test3();
- }
-
- private static void test3() {
- test2();
- }
- public static void main(String[] args) {
- System.out.println(f(5));
- }
-
- public static int f(int n) {
- if(n == 1){
- return 1;
- }else{
- return f(n - 1) * n;
- }
-
- }
- public static void main(String[] args) {
- System.out.println(f(5));
- }
-
- public static int f(int n) {
- if(n == 1){
- return 1;
- }else{
- return f(n - 1) + n;
- }
-
- }
- public static void main(String[] args) {
- //猴子吃桃问题:后一天吃的都是前一天桃子数量的一半再减一个
- //f(x) - f(x) / 2 - 1 = f(x + 1) x是天数
- //2f(x) - f(x) - 2 = 2f(x + 1)
- //f(x) = 2f(x + 1) + 2
- System.out.println(f(1));
- System.out.println(f(2));
- System.out.println(f(3));
- System.out.println(f(4));
- System.out.println(f(5));
- }
-
- public static int f(int x) {
- if(x == 10){
- return 1;
- }else{
- return 2 * f(x + 1) + 2;
- }
-
- }