Skip to content

Instantly share code, notes, and snippets.

@Bablzz
Last active September 18, 2019 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bablzz/69873b2eae373016d88237c664cc6b73 to your computer and use it in GitHub Desktop.
Save Bablzz/69873b2eae373016d88237c664cc6b73 to your computer and use it in GitHub Desktop.
Fibonacci Binet
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