Created
January 15, 2009 23:35
-
-
Save metaskills/47697 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /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