mirror of https://github.com/coolaj86/fizzbuzz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
304 B
21 lines
304 B
package main
|
|
|
|
import "fmt"
|
|
|
|
// fibonacci is a function that returns
|
|
// a function that returns an int.
|
|
func fibonacci() func() int {
|
|
a := 0
|
|
b := 1
|
|
return func () int {
|
|
a, b = b, a + b;
|
|
return a;
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
f := fibonacci()
|
|
for i := 0; i < 10; i++ {
|
|
fmt.Println(f())
|
|
}
|
|
}
|
|
|