FAN AND MEDAL: 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
@mustafa2014 @hartnn
Okay: try putting n = 3 in the given equation.
f(3-1) + f(3-2) ?
good so, f(3) = f(3-1) + f(3-2) = f(2) + f(1) Now you already know f(1) and f(2). So, plug in the values and find out f(3).
Can you tell me what do you obtain ?
f(3) = f(2) + f(1) = 0 + 1 f(3) = 0 + 1 = 1 f(3) = 1 = 1 ?????
Great ! Now similarly find out f(4) and tell me its value. Remember now you have f(1),f(2) and f(3) already known so you can use their values as and when necessary.
f(4) = 2 ?
great work now f(5) ?
f(5) = 4
How ?
sorry, i meant to put 3
wait, its 2 isnt it?
@kaylamarie101 write f(5) in terms of f(n-1) and f(n-2), first. What do you get?
ugh, im lost again. It'd be f(4) + f(3) + f(2) + f(1) So, 2 + 1 + 0 +1..so wouldn't I have been right the first time?
No No
See: for obtaining f(3) I asked you to put n = 3 and you did the same. for obtaining f(4), put n = 4, you will get: f(4) = f(4-1) + f(4-2) = f(3) + f(2) Now you had already calculated f(3) and f(2) was given to you so you had to just plug in those values to get the value of f(4). Do you understand this ?
Yes, And I got f(4)...so would it now be: f(5)= f(5-1) + f(5-2) = f(4) + f(3) ?
perfect !!
Now tell me value of f(5).
Okay, so: f(5)= f(4) + f(3) = f(4) + f(3) f(5) = 2 + 1 = 2+1 f(5) = 3 = 3 So, f(5) = 3 Which then means that the answer to the original problem is: 0, 1, 1, 2, 3 Right? (:
@vishweshshrimali5
You are correct. But, as @hartnn pointed out a mistake: the sequence says n>2, so, the first 5 terms would be f(3), f(4),..f(7). So, you just have to calculate f(6) and f(7) also.
Okay, f(6) = f(6-1) + f(6-2) = f(5) + f(4) f(6) = f(5) + f(4) f(6) = 3 +2 = 5
Good
f(7) = f(7-1) + f(7-2) = f(5) + f(6) f(7) = f(6) + f(5) = f(5) + f(6) f(7) = 5 + 3= 8 f(7) = 8
Great work
So your required answer is ?
I'm unsure...where do I go from here?
See, the question asks for first 5 terms and they would be f(3),f(4),f(5),f(6),f(7). So, in place of f(...), write its value and that's your final answer.
Okay! I get it now...So, it would be: 1, 2, 3, 5, 8
Good
Awesome! Thanks so much! :D
no problem and keep this great work.
Join our real-time social learning platform and learn together with your friends!