Created
October 15, 2019 03:16
-
-
Save m2kar/21f727700abd4a2de7af47f41a8590b6 to your computer and use it in GitHub Desktop.
斐波拉契数列 公式法 Go实现
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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