Last active
January 15, 2017 00:10
-
-
Save amstee/f5d0887ce5f929bf4b77f70a3c22c30b to your computer and use it in GitHub Desktop.
An answer for the exercise fibonacci
This file contains 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
func fibonacci() func() int { | |
a, b := -1, 1 | |
return func() int { | |
if a == -1 { | |
a = 0 | |
return a | |
} | |
a, b = b, a + b | |
return a | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment