Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 379 Bytes

递归解决斐波那契数列.md

File metadata and controls

18 lines (17 loc) · 379 Bytes
/**
* 使用递归计算斐波那契数列
* 1 1 2 3 5 8 13 21 34 55 
*/
public class Fibonacci {  
    public int fibonacciArr(int n){    
        if (n == 1){          
            return 1;      
        }else if (n == 2){  
            return 1;     
        }else {       
            return fibonacciArr(n - 1) + fibonacciArr(n - 2);     
        }   
    }
}