Last active
January 23, 2020 23:20
-
-
Save ptflp/f67cde81d3d6728d4bf710377458761d to your computer and use it in GitHub Desktop.
fibonacci sequence golang implementation
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
package main | |
import ( | |
"fmt" | |
) | |
func fib() func() int{ | |
a, b := 0, 1 | |
return func() int{ | |
a, b = b, a+b | |
return b-a | |
} | |
} | |
func main() { | |
t := fib() | |
for i:=0; i < 20; i++{ | |
fmt.Println(t()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment