Skip to content

Commit

Permalink
Create fibonacci.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
JAmixer committed Oct 1, 2018
1 parent d0b29b5 commit ddfccdd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fibonacci/fibonacci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def fib(n)

if n == 0
return 0
end
if n == 1
return 1
end

if n >= 2
return fib(n-1) + (fib(n-2))
end

end

0 comments on commit ddfccdd

Please sign in to comment.