Skip to content

Instantly share code, notes, and snippets.

@fogonthedowns
Created June 4, 2014 05:31
Show Gist options
  • Save fogonthedowns/51b8ec1b7976f38b0657 to your computer and use it in GitHub Desktop.
Save fogonthedowns/51b8ec1b7976f38b0657 to your computer and use it in GitHub Desktop.
swift fibonacci number
// Playground - noun: a place where people can play
// swift fibonacci number
// Justin Zollars
// jz.io
import Cocoa
var answer = fib(5)
func fib(start: Int) -> Int {
if start == 0 {
return start
}
if start == 1 {
return start
}
return (fib(start - 1) + fib(start - 2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment