Fibonacci sequence function problem
4 次查看(过去 30 天)
显示 更早的评论
I used this code to find the number of even elements in the Fibonacci Sequence up to a given number 'd'.
function y = evenFibo(d)
k = 0;
for i = 1:1:d
a = fibonacci(i);
if rem(a,2)==0
k = k+1;
else
k = k+0;
end
end
y = k;
end
But , it's repeatedly showing that "Undefined function 'fibonacci' for input arguments of type 'double'". How can I solve this problem?
0 个评论
回答(1 个)
James Tursa
2018-4-9
编辑:James Tursa
2018-4-9
The fibonacci( ) function was introduced in R2017a. What version of MATLAB are you running?
If you are running an earlier version, try this FEX submission from John D'Errico:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!