Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (18 sloc) 304 Bytes
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())
}
}
Jump to Line
Something went wrong with that request. Please try again.