Last active
September 18, 2019 09:02
-
-
Save Bablzz/69873b2eae373016d88237c664cc6b73 to your computer and use it in GitHub Desktop.
Fibonacci Binet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib = 9 | |
def BinetFib number | |
phi = ((1 + Math.sqrt(5)) / 2) #or 1.6180339887 | |
divid = phi**number | |
divider = Math.sqrt(5) | |
(divid / divider).round | |
end | |
puts BinetFib(fib); | |
# => 34 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment