I need to check my answer please! I chose B. 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
@ganeshie8
yeah generate the first 5 terms... where exactly are you stuck ?
Notice that you're already given the first two terms : ``` f(1) = 0 f(2) = 1 ```
im not stuck i just want to make sure im correct
So the sequence stars like below : 0, 1, ...
and i know it's not A
thats a very good start !
lets generate the third term
looks we're given a formula for generating terms ?
` f(n) = f(n - 1) + f(n - 2)` plugin n = 3, you wil get the 3rd term : f(3) = f(3-1) + f(3-2) = f(2) + f(1) = ?
the thing is that i dont really know how to add f(2) + f(1) because the lesson did not really explain everything to me... i read it over again like 3 times.. :(
f(2) = second term f(1) = first term
just add the first and second terms to get the third term :)
1
Perfect ! f(3) = third term = 1
So far the sequence is : 0, 1, 1,...
see if u can generate the 4th term
2
Yes ! 0, 1, 1, 2,...
what about 5th term ?
3
Yep ! good job !!
thanks! :)
Join our real-time social learning platform and learn together with your friends!