7____ Fibonacci number

Subject description:

We all know that Fibonacci number, and now asked to enter an integer n, you output the n-th Fibonacci number Fibonacci sequence of item (from 0, the first 0 is 0).

n<=39。

public  class Solution {
     // find the first Fibonacci n terms of Number of 
    public  int Fibonacci ( int n) {
         // Fibonacci series Amount: 0,1,1,2,3,5. . . .
        // next number is the first two digits and 
        int prepreNum = 0 ;
         int preNum =. 1 ;
         int RES = 0 ;
         IF (0 == n-) {
             return 0 ; 
        } 
        IF (. 1 == n-) {
             return . 1 ; 
        } 
        
        for ( int I = 2; I <= n-; I ++ ) {
            true = + prepreNum preNum; 
            prepreNum = preNum; 
            preNum = true; 
        } 
        Return true; 
    } 
}

Fibonacci series Amount: 0,1,1,2,3,5 .. . . . Value of the current element is the index values ​​and the first two elements.

Guess you like

Origin www.cnblogs.com/xbfchder/p/11448403.html