mirror of https://github.com/ray-x/go.nvim
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
401 B
Go
25 lines
401 B
Go
package pkg
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func Fib(n string) string {
|
|
nn, _ := strconv.Atoi(n)
|
|
if nn < 2 {
|
|
r := strconv.Itoa(nn)
|
|
return r
|
|
}
|
|
n1, _ := strconv.Atoi(Fib(strconv.Itoa(nn - 1)))
|
|
n2, _ := strconv.Atoi(Fib(strconv.Itoa(nn - 2)))
|
|
return strconv.Itoa(n1 + n2)
|
|
}
|
|
|
|
func BenchmarkFib10(b *testing.B) {
|
|
// run the Fib function b.N times
|
|
for n := 0; n < b.N; n++ {
|
|
Fib("10")
|
|
}
|
|
}
|