Created
October 22, 2018 23:30
-
-
Save rranelli/721d23b716b90bcf7c173340325d1b52 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
# fibo O(n^2) | |
def fib(n) | |
raise ArgumentError if n < 0 | |
if n == 0 || n == 1 | |
1 | |
else | |
fib(n-1) + fib(n -2) | |
end | |
end | |
(1..30).each do |n| | |
puts "#{n} => #{fib(n)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment