2019.12.14 递归类型题

/**
* DiGui.java
* com.DuiXiang
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月14日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.DuiXiang;
/**
* ClassName:DiGui
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月14日 下午2:52:23
*
* @see
*/
public class DiGui {
public static void main(String[] args) {

System.out.println(func1(10));
}
public static int diGui(int x) {
if (x==1) {
return 1;
}else {
return x*diGui(x-1);
}
}
public static int func(int x) {
if (x==0) {
return 1;
}else if(x==1){
return 4;
}else {
return 2*func(x-1)+func(x-2);
}

}
public static int func1(int x) {
if (x==20) {
return 1;
}else if(x==21){
return 4;
}else {
return func1(x+2)-2*func1(x+1);
}

}
public static int Fibonacci(int x) {
if (x==1) {
return 1;
}else if(x==2){
return 1;
}else {
return Fibonacci(x-2)+Fibonacci(x-1);
}
}
}

猜你喜欢

转载自www.cnblogs.com/aojie/p/12041209.html
今日推荐