Created
May 5, 2023 12:44
-
-
Save kbakdev/c68d40c76a63c8fcb636afd61bf4a89d to your computer and use it in GitHub Desktop.
Binet's Formula Go
This file contains 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
func FibonacciBinet(n int) int { | |
sqrt5 := math.Sqrt(5) | |
phi := (1 + sqrt5) / 2 | |
return int(math.Round(math.Pow(phi, float64(n)) / sqrt5)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment