Skip to content

Instantly share code, notes, and snippets.

@sherifflight
Created July 18, 2019 20:52
Show Gist options
  • Save sherifflight/5d3f093aac3a2764ae23f0dfdde6dcab to your computer and use it in GitHub Desktop.
Save sherifflight/5d3f093aac3a2764ae23f0dfdde6dcab to your computer and use it in GitHub Desktop.
Fibonachi
func fibonachi (n: Int) -> Int {
guard n > 1 else {
return 1
}
var prev = 0
var cur = 1
for _ in 1..<n {
(prev, cur) = (cur, prev + cur)
}
return cur;
}
fibonachi(n: 6) //return 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment