package main

//Covers "Exercise: Fibonacci closure"

import "fmt"

// fibonacci is a function that returns
// a function (i.e. a closure) that returns an int.
func fibonacci() func() int {
	a := 0
	b := 1
	
	return func() int {
		c := a
		a = b
		b += c
		
		return c
	}
}

func main() {
	f := fibonacci()
	for i := 0; i < 10; i++ {
		fmt.Println(f())
	}
}