Skip to content

Instantly share code, notes, and snippets.

@seanreed1111
Last active December 31, 2015 17:59
Show Gist options
  • Save seanreed1111/8024044 to your computer and use it in GitHub Desktop.
Save seanreed1111/8024044 to your computer and use it in GitHub Desktop.
Fibonacci Sequence with Memoization
@fib_hash = {}
@fib_hash = {0 => 0, 1 => 1 }
def fibo_finder(n)
if @fib_hash.has_key?(n)
return @fib_hash[n]
else
@fib_hash[n] = fibo_finder(n-1) + fibo_finder(n-2)
end
end
puts fibo_finder(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment