doubt is in function loop initialize i =1, and end n-2
why ending n-2 ?
Doubt about fibonacci number
hello @mohitenikhil888
in the later part of the video. bahiya made it n-1.
reason
a) we are counting from 0 (i.e we are considering 0 the first fibonnaci is at 0th place)
comsider this example where we have to find 6th fibonnaci no->
a=0
b=1
then we iterate n-1 times ( n is 6 so n-1 will be 5)
1st iteration -> c will be 1
2nd iteration -> c will be 2
3rd iteration -> c will be 3
4th iteration -> c will be 5
5th iteration -> c will be 8
so thats how 6th fib is coming 8.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.