Skip to content

Instantly share code, notes, and snippets.

@kbakdev
Created May 5, 2023 12:44
Show Gist options
  • Save kbakdev/c68d40c76a63c8fcb636afd61bf4a89d to your computer and use it in GitHub Desktop.
Save kbakdev/c68d40c76a63c8fcb636afd61bf4a89d to your computer and use it in GitHub Desktop.
Binet's Formula Go
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