Created
June 4, 2014 05:31
-
-
Save fogonthedowns/51b8ec1b7976f38b0657 to your computer and use it in GitHub Desktop.
swift fibonacci number
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
// 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