Skip to content

Instantly share code, notes, and snippets.

@nthState
Last active August 29, 2015 14:02
Show Gist options
  • Save nthState/79273090be5c3289b0c9 to your computer and use it in GitHub Desktop.
Save nthState/79273090be5c3289b0c9 to your computer and use it in GitHub Desktop.
Swift Fib
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