Skip to content

Instantly share code, notes, and snippets.

@m2kar
Created October 15, 2019 03:16
Show Gist options
  • Save m2kar/21f727700abd4a2de7af47f41a8590b6 to your computer and use it in GitHub Desktop.
Save m2kar/21f727700abd4a2de7af47f41a8590b6 to your computer and use it in GitHub Desktop.
斐波拉契数列 公式法 Go实现
import (
"math"
)
func fib(N int) int {
N=N-1;
s5:=math.Sqrt(5);
return int(math.Round((math.Pow((1+s5)/2 , float64(N+1)) - math.Pow((1-s5)/2, float64(N+1))) /s5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment