Created
June 8, 2019 20:38
-
-
Save davidinga/4743e4fa67cfef5d5e67505b5315630d to your computer and use it in GitHub Desktop.
Returns the nth number in the Fibonacci Sequence.
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
| func recursiveFib(_ n: Int) -> Int { | |
| if n < 2 { | |
| return n | |
| } else { | |
| return recursiveFib(n - 2) + recursiveFib(n - 1) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment