Created
November 14, 2017 21:03
-
-
Save titanium-cranium/92a966f6ea8c31ba140a2b5eda0ae4f5 to your computer and use it in GitHub Desktop.
Recursive version returning the value of an element in the fibonacci series
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
| def fib(n) | |
| return n if (0..1).include? n | |
| fib(n-1) + fib(n-2) if n > 1 | |
| end | |
| puts fib(7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment