Skip to content

Instantly share code, notes, and snippets.

@carlogilmar
Created November 29, 2017 05:17
Show Gist options
  • Save carlogilmar/6f16b309fd15ee24e70346801587437b to your computer and use it in GitHub Desktop.
Save carlogilmar/6f16b309fd15ee24e70346801587437b to your computer and use it in GitHub Desktop.
Third Fibonacci Solution
/* Tercera Versión */
func fib3(n:UInt) -> UInt{
if (n==0){
return n
}
var last: UInt = 0
var next: UInt = 1
for _ in 1..<n{
(last, next) = (next, last+next)
}
return next
}
fib3(n: 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment