Rather than computing out the whole Fibonacci sequence and check if $n$ is even and in there, is there a more straightforward way to compute if $n$ is a even Fibonacci number?
Asked
Active
Viewed 222 times
3
-
3See wiki – Michael Galuza Jul 18 '15 at 16:41
-
1http://math.stackexchange.com/questions/9999/checking-if-a-number-is-a-fibonacci-or-not – mathlove Jul 18 '15 at 16:43
2 Answers
2
The $n^\text {th} $ Fibonacci number is given by $$ F_n=\frac {\phi^n-(-\phi)^{-n}}{\sqrt {5}}, $$ where $\phi $ is the golden ratio. If your number is $x $, then you could try $$\frac {\cosh^{-1}(\sqrt {5}x/2)}{\ln\phi}.$$ If this is an even integer, then $x $ is a Fibonacci number. Also if $$\frac {\sinh^{-1}(\sqrt {5}x/2)}{\ln\phi}$$ is odd.

Plutoro
- 22,730
- 3
- 41
- 71
-
It's definitely true, but I don't think that using of golden ratio is a good idea. In my opinion, question related to very big numbers (small numbers we can find in a table or check OEIS for its), and you should use only integer operations (even if it's integer square root) – Michael Galuza Jul 18 '15 at 16:54
-
-
of course no, it's my awful English. I want to say that $\sqrt5$ and $\ln\phi$ should not be used – Michael Galuza Jul 18 '15 at 17:01
0