F(n) = F(n-1) + F(n-2):
Can someone explain to me how to use this formula, and maybe show an example. I'm uncertain of what I'm supposed to be plugging in for 'n'.
![]()
Pick a first number - say, 3 - and call it F(1), meaning the first number in the sequence. Then pick a second number - perhaps 5 - and assign this to F(2). To find the third number F(3) you use F(3)= F(2) + F(1) = 5 + 3 = 8. Then to find the 4th you use F(4) = F(3) + F(2) = 8 + 5 = 13. In general, to find the nth number in the sequence you add F(n-1) and F(n-2) together. Typically people start the Fibonacci series off with F(1) =1 and F(2)=1, but you don't have to. This leads to:
F(1) = 1
F(2) = 1
F(3) = 2
F(4) = 3
F(5) = 5
F(6) = 8
F(7) = 13
F(8) = 21
etc.
Hope this helps!
Well, it was part of a problem I had to do for school. When I was given a number I was supposed to correspond with a Fibonacci number. I guess like:
1. 1
2. 2
3. 3
4. 5
5. 8
6.13
So, if I wanted to find the Fibonacci number for 2 (which is two), I thought I'd let n be 2 and plug it in...
F(2)=F(2-1)+F(2-2)
F(2)=F(1)+F(0)
but F(1)+F(0)=F(1)?
but the fibonacci number for 2 isn't 1 is it?
I'm a little confused here![]()
A more suggestive and general approach is to consider the Fibonacci sequence as solution of the difference equation...
(1)
... with 'initial consitions'and
. If u and v are solution of the second order equation...
(2)
... then the solution of (1) is of the form...
(3)
In this case is...
![]()
(4)
... and the constantsand
are found imposing the initial conditions and solving the system...
![]()
(5)
Kind regards
![]()
![]()