@AgreeableLandscapeM to Programmer Humor • 2 years agoThe O(1) Fibonacci implementationimagemessage-square8arrow-up162arrow-down14
arrow-up158arrow-down1imageThe O(1) Fibonacci implementation@AgreeableLandscapeM to Programmer Humor • 2 years agomessage-square8
minus-square@ishigami_sanlink1•2 years agoghci> φ = (1 + sqrt 5) / 2 ghci> ψ = 1 - φ ghci> fib n = (φ ** n - ψ ** n) / (sqrt 5)
ghci> φ = (1 + sqrt 5) / 2 ghci> ψ = 1 - φ ghci> fib n = (φ ** n - ψ ** n) / (sqrt 5)