Skip to content

Instantly share code, notes, and snippets.

@davidinga
Created June 8, 2019 20:38
Show Gist options
  • Select an option

  • Save davidinga/4743e4fa67cfef5d5e67505b5315630d to your computer and use it in GitHub Desktop.

Select an option

Save davidinga/4743e4fa67cfef5d5e67505b5315630d to your computer and use it in GitHub Desktop.
Returns the nth number in the Fibonacci Sequence.
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