Mom: what is Fibonacci Series?
Abhi: Fibonacci series is 1,1,2,3,5,8,13,21,34,55
Now I will write code for getting this sequence .
f(0)=1, f(1)=1
f(2)=f(0)+f(1)
f(3)=f(2)+f(1)
f(4)=f(3)+f(2)
f(5)=f(4)+f(3)
M: do you see a pattern? Can you write it in a generalized form?
A: yes.
f(n)=f(n-1)+f(n-2)
M: what should you do next?
A: n=2
M: and?
A: N goes upto whatever we want, say 10
M: how else can you say that?
A: I can say repeat my formula for n=2 to n=10
Cool I got it.
While(n=2,n<10){
f(n)=f(n-1)+f(n-2)
n=n+1 }
M: good, anything else you can think of to make it more efficient?
A: No
M: how about n, can you start it at 0?
A: I could not start n from 0 or 1 because I need a starting point.
M: Anything else?
A: no post mommy.