Skip to content

Instantly share code, notes, and snippets.

@luchuan
Created June 4, 2014 17:52
Show Gist options
  • Save luchuan/6d0f95ddf793c156896b to your computer and use it in GitHub Desktop.
Save luchuan/6d0f95ddf793c156896b to your computer and use it in GitHub Desktop.
// Playground - noun: a place where people can play
import Cocoa
func main() {
func _fib(x: Int, y: Int, i: Int) -> Int {
if i == 1 || i == 0 {
return x + y
} else {
return _fib(y, x + y, i - 1)
}
}
func fib(n: Int) -> Int {
if n == 0 {
return 0
}
return _fib(0, 1, n)
}
fib(10)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment