TITLE: How are we able to calculate specific numbers in the Fibonacci Sequence?
QUESTION [42 upvotes]: I was reading up on the Fibonacci Sequence, $1,1,2,3,5,8,13,\ldots $ when I noticed some were able to calculate specific numbers. So far I've only figured out creating an array and counting to the value, which is incredibly simple, but I reckon I can't find any formula for calculating a Fibonacci number based on it's position.
Is there a way to do this? If so, how are we able to apply these formulas to arrays?

REPLY [3 votes]: This is an old post, but still... The relation 
$$
F_0=1, F_1 =1, F_n = F_{n-1}+F_{n-2}, n \ge 2
$$
defines a linear second order homogeneous difference equation. The solution can be found after computing the roots of the associated characteristic polynomial $p(\lambda)=\lambda^2-\lambda -1$, which are $\lambda = \frac{1 \pm \sqrt{5}}{2}$. The general solution is then given by
$$
F_n= C_1 \left(\frac{1 + \sqrt{5}}{2} \right)^n + C_2 \left(\frac{1 - \sqrt{5}}{2} \right)^n
$$
and the constants $C_1, C_2$ are computed knowing that $F_0 = F_1 = 1$. so, finally,
$$
F_n= \frac{1}{\sqrt{5}} \left(\frac{1 + \sqrt{5}}{2} \right)^n - \frac{1}{\sqrt{5}} \left(\frac{1 - \sqrt{5}}{2} \right)^n
$$
This is obviously equivalent to Binet's formula, but provides a general process to deal with linear recurrences.