Last active
December 9, 2015 19:28
-
-
Save georgespingos/4317570 to your computer and use it in GitHub Desktop.
Calculate Fibonacci without recursion or loops !! (Math hack)
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
public static double SuperCoolFibonacci(int n) | |
{ | |
return Math.Round((Math.Pow(0.5 + 0.5 * Math.Sqrt(5.0), n) - Math.Pow(0.5 - 0.5 * Math.Sqrt(5.0), n)) / Math.Sqrt(5.0), MidpointRounding.AwayFromZero); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment