fibonacci of 6

Solutions on MaxInterview for fibonacci of 6 by the best coders in the world

showing results for - "fibonacci of 6"
Adalia
26 Jun 2016
1f(n) = f(n-1) + f(n-2) 
2                                  f(6)
3                                   ^
4  			                       /\
5                f(5)               +                       f(4)
6                ^
7               /\                   +                        /\
8                
9        f(4)    +           f(3)                     f(3)    +    f(2)
10       ^                       ^                     ^              ^
11      /\                       /\                    /\            /\
12   
13 f(3)   +       f(2)            f(2) + f(1)       f(2) + f(1)   f(1) +  f(0)             
14   ^              ^                ^                ^
15   /\             /\                /\              /\
16    
17f(2) + f(1)      f(1) +  f(0)     f(1)+ f(0)       f(1) + f(0)         
18  ^
19  /\
20f(1) +  f(0) 
21  
22//f(6) = 8   ==>  f(1)*8    f(1) appears 8 times 
23 double feb  = (1/Math.pow(5,0.5)) * (Math.pow((1+Math.pow(5,0.5))/2,n)) - (1/Math.pow(5,0.5))* (Math.pow((1-Math.pow(5,0.5))/2,n));  
24  
25f(1) == 1;   
26  
27  
28  
29  
30  
31  
32