package main
import "fmt"
var memo = make(map[int]int)
func fib(n int) int {
if _, ok := memo[n]; ok {
return memo[n]
}
var result int
if n <= 2 {
result = 1
} else {
result = fib(n - 1) + fib(n - 2)
}
memo[n] = result
return result
}
func main() {
for i := 1; i < 10; i++ {
fmt.Println(fib(i))
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: