Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created January 15, 2009 23:35
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 metaskills/47697 to your computer and use it in GitHub Desktop.
Save metaskills/47697 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'time'
puts "starting fibonacci"
def fib(num)
if(num < 2)
return 1
else
return fib(num-1) + fib(num-2)
end
end
if ARGV[0] != nil
if (ARGV[0].to_i >= 35)
puts "This might take a bit...."
end
start = Time.now
puts fib(ARGV[0].to_i)
stop = Time.now - start
puts "Finding the fib of #{ARGV[0]} took:"
puts stop
puts "seconds"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment