Fibonacci numbers

FROM

time complexity : O(lgN)
idea

clipboard.png

F2n-1 = Fn^2 + (Fn-1)^2

F2n = (2*Fn-1 + Fn)*Fn 
If n is even then k = n/2:
    F(n) = [2*F(k-1) + F(k)]*F(k)

If n is odd then k = (n + 1)/2
    F(n) = F(k)*F(k) + F(k-1)*F(k-1)

shiyang6017
158 声望59 粉丝

引用和评论

0 条评论