Created
November 29, 2017 05:17
-
-
Save carlogilmar/6f16b309fd15ee24e70346801587437b to your computer and use it in GitHub Desktop.
Third Fibonacci Solution
This file contains 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
/* 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