Generate the first 5 terms of this sequence: f(1) = 0 and f(2) = 1, f(n) = f(n - 1) + f(n - 2), for n > 2. 0, -1, 1, 0, 2 0, 1, 1, 2, 3 0, 1, 2, 2, 3 0, 1, 1, 2, 2
The next number is 3. So you plug in n = 3.
f(3) = f(3 - 1) + f(3-2) Solve.
That would be: f(3) = f(2) + f(1)
Now plug in for f(2) and f(1). f(3) = 1 + 0
f(3) = 1
Do the same for 4 and 5. Tell me if you need help.
Im not really good with these problems. Can you explain to me how to do it correctly?
Yeah
Now we can plug in 4.
Tell me if you need help.
I dont mean like whats the next thing i do in this problem. I wanna know how to do any problems that are similar to this one
Plug in 4. so, here is our original equation. f(n) = f(n - 1) + f(n - 2) n is just a variable. so for n, we plug in 4. f(4) = f(4-1) + f(4 - 2)
Can you solve for f(4) = f(4-1) + f(4 - 2)
f(4) = f(4) -1 + f(4) -2? Or f(3) + f(2) One of these ways?
The second is correct!
Now we plug in! Since we already know: f(3) = 1 f(2) = 1 f(4) = 1 + 1
That means f(4) = 2
Lets clean this up! f(1) = 0 f(2) = 1 f(3) = 1 f(4) = 2 f(5) = ?
We need to find one more!
f(4) + f(3) ?
Yes!
Now, plug in the numbers.
This last part is what gets me kind of confused. I got the f(4) + f(3) Do i go like this? f(4) = 1 f(3) =1 f(5) = 2?
f(4) = 2 actually. We know this because when we solved for f(4) already. These problems are in a series of steps, to get one answer you have to know other so on and so on.
See, when we solve for f(4) = f(4 - 1) + f(4 - 2) f(4) = f(3) + f(2) f(4) = 1 + 1 f(4) = 2 Do you see how we had to know what f(3) and f(2) were to know what f(4) is?
Since we are solving for f(5) we had to know what f(4) is, and we do, because we did the equation before hand.
so its f(5) = 3?
Great job!
Do you want to see what f(6) is for extra help?
Sure. f(6) = f(6-1) + f(6 - 2) f(6) = f(5) + f(4) F(6) = 4?
Remember that f(5) = 3 and f(4) = 2
so, f(6) = 3 + 2 f(6) = 5
So for f(7) f(7) = f(7-1) + f(7 - 2) f(7) = f(6) + f(5) f(7) = 5+3? Do i take the last two answers?
Yes! Very good!
This is known as a recursive formula.
It needs previous answers to make the new answer.
f(8) = f(8-1) + f(8 - 2) f(8) = f(7) + f(6) f(8) = 8 + 5?
Great! You are getting the hang of it. Now, since it just needed the first 5, we already have the answer. Do you which one it is?
The second option
Great!
Thanks!
No problem! Do you want extra practice?
Sure
f(1) = 2 and f(2) = 3, f(n) = f(1) + f(2) + f(n - 1), for n > 2. Solve for the first 5
I am going to have to go soon, but if you need any help you can message me, :)
Ok thanks. Ill practice these in my notebook.
No problem. Thanks for the metal!
Join our real-time social learning platform and learn together with your friends!