Files
monkey/examples/fib.go
Chuck Smith fb0cebaf56
Some checks failed
Build / build (push) Failing after 5m54s
Publish Image / publish (push) Failing after 35s
Test / build (push) Failing after 5m46s
bunch of changes
2024-03-28 17:19:23 -04:00

26 lines
257 B
Go

//go:build ignore
package main
import (
"fmt"
"os"
"strconv"
)
func fib(x int) int {
if x < 2 {
return x
}
return fib(x-1) + fib(x-2)
}
var n = 35
func main() {
if len(os.Args) > 2 {
n, _ = strconv.Atoi(os.Args[1])
}
fmt.Println(fib(n))
}