Skip to content

Instantly share code, notes, and snippets.

@mckinnsb
Created October 3, 2011 16:33
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 mckinnsb/1259537 to your computer and use it in GitHub Desktop.
Save mckinnsb/1259537 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'ruby-debug'
fibonacci = ->n do
if (n < 2)
1
else·
(fibonacci.call(n - 2) + fibonacci.call(n - 1))
end
end
get "/fib" do
now_time = Time.now
value = fibonacci.call(40)
then_time = Time.now
duration = then_time - now_time
"Fibonacci 40 time is : #{duration}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment