Created
October 13, 2020 05:28
-
-
Save aershov24/5793a9381c35d6c74c17c2c3d8761e04 to your computer and use it in GitHub Desktop.
Markdium-14 Fibonacci Interview Questions (SOLVED) To Brush Before Coding Interview
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
| bool isFibonacci(int w) | |
| { | |
| double X1 = 5 * Math.Pow(w, 2) + 4; | |
| double X2 = 5 * Math.Pow(w, 2) - 4; | |
| long X1_sqrt = (long)Math.Sqrt(X1); | |
| long X2_sqrt = (long)Math.Sqrt(X2); | |
| return (X1_sqrt*X1_sqrt == X1) || (X2_sqrt*X2_sqrt == X2) ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment