Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 function [result] = Fibonacci(n)
- 2 y=[1,1];
- 3 i=2;
- 4 if n==0
- 5 result=1;
- 6 elseif n==1
- 7 result=1;
- 8 else
- 9
- 10 while i n
- 11 y=[y(2) , y(2)+y(1)];
- 12
- 13 i=i+1;
- 14 end;
- 15 result=y(1,2);
- 16 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement