1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//nolint:all // Linter is executed at the same time as tests which leads to race conditions and failures.
package main
import (
"fmt"
)
func foo() {
fmt.Println("foo")
}
func FibonacciHelper(n uint) (uint64, error) {
func() {
foo()
}()
return Fibonacci(n)
}
func Fibonacci(n uint) (uint64, error) {
if n <= 1 {
return uint64(n), nil
}
if n > 93 {
return 0, fmt.Errorf("unsupported fibonacci number %d: too large", n)
}
var n2, n1 uint64 = 0, 1
for i := uint(2); i < n; i++ {
n2, n1 = n1, n1+n2
}
return n2 + n1, nil
}
|