Skip to content

Instantly share code, notes, and snippets.

@amstee
Last active January 15, 2017 00:10
Show Gist options
  • Save amstee/f5d0887ce5f929bf4b77f70a3c22c30b to your computer and use it in GitHub Desktop.
Save amstee/f5d0887ce5f929bf4b77f70a3c22c30b to your computer and use it in GitHub Desktop.
An answer for the exercise fibonacci
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