Friday, February 03, 2006
Recursive Function
Recursive Function in Matlab
f = [1 1]; n = 1; while f(n) + f(n + 1) < 80 f(n + 2) = f(n) + f(n + 1); n = n + 1; end f function f = fibfun(n) % Incidentally, the name Fibonacci comes from Filius Bonassi, or "son of Bonassus". if n > 2 f = fibfun(n - 1) + fibfun(n - 2); else f = 1; end end