Consider this Fibonacci equation: $$f_{n+1}^2 - f_nf_{n+2}$$
The problem asked to write a program with given n
, output the the result of this equation. I could use the formula
$$f_n = \frac{(1+\sqrt{5})^n - ( 1 - \sqrt{5} )^n}{2^n\sqrt{5}}$$
However, from mathworld, I found this formula Cassini's identity
$$f_{n-1}f_{n+1} - f_{n}^2 = (-1)^n$$
So, I decided to play around with the equation above, and I have:
$$ \text{Let } x = n + 1 $$ $$ \text{then the equation above becomes } f_x^2 - f_{x-1}f_{x+1} $$ $$ \Rightarrow -( f_{x-1}f_{x+1} - f_x^2 ) = -1(-1)^x = (-1)^{x+1} = (-1)^{n+1+1} = (-1)^{n+2}$$
So this equation either is 1 or -1. Am I in the right track?
Thanks,
Chan