qq_32686815
Macmanboy
2017-10-12 04:30

MATLAB中fibnum(n)函数的执行时间T(n)与n的函数关系是什么?

50
  • matlab
  • 函数

function f = fibonacci(n)
%FIBONACCI Fibonacci sequence
% f = FIBONACCI(n) generates the first n Fibonacci numbers.

% Copyright 2014 Cleve Moler
% Copyright 2014 The MathWorks, Inc.
f = zeros(n,1);
f(1) = 1;
f(2) = 2;
for k = 3:n
f(k) = f(k-1) + f(k-2);
end

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答