Prob. 2, ch 6, p230
2 ways to define Fibonacci function
F(n) = nth element in series
1, 1, 2, 3, 5, 8, 13, 21, ...
[Each number is sum of 2 predecessors.]
I.
f(0) Þ 1;
f(1) Þ 1;
f(N) Þ f(N-1)+f(N-2);
II.
int K,F,G,N,temp;
N = position in series
K = 0;
F = 1;
G = 0;
while(K < N)
{
temp = F;
F = F + G;
G = temp;
K++;
}
return value of F;