Last active
August 29, 2015 14:02
-
-
Save nthState/79273090be5c3289b0c9 to your computer and use it in GitHub Desktop.
Swift Fib
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
struct Fib { | |
var current: Int = 1; | |
var last: Int = 0; | |
mutating func next() { | |
let tmp = current; | |
current += last; | |
last = tmp; | |
print("Current: \(current) Last: \(last) "); | |
} | |
} | |
var s = Fib() | |
for _ in 0...20 { | |
s.next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment