Fast Fibonacci computation

前端 未结 4 1799
失恋的感觉
失恋的感觉 2021-02-04 17:56

I saw a comment on Google+ a few weeks ago in which someone demonstrated a straight-forward computation of Fibonacci numbers which was not based on recursion and didn\'t use mem

4条回答
  •  迷失自我
    2021-02-04 18:54

    From Wikipedia,

    For all n ≥ 0, the number Fn is the closest integer to phi^n/sqrt(5) where phi is the golden ratio. Therefore, it can be found by rounding, that is by the use of the nearest integer function

提交回复
热议问题