bunch of changes
This commit is contained in:
25
examples/fib.go
Normal file
25
examples/fib.go
Normal file
@@ -0,0 +1,25 @@
|
||||
//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))
|
||||
}
|
||||
Reference in New Issue
Block a user