Fibonacci sequence function problem

조회 수: 4 (최근 30일)
Mohammad Abir Hassan Sarker
Mohammad Abir Hassan Sarker 2018년 4월 9일
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?

답변 (1개)

James Tursa
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:
  댓글 수: 1
Mohammad Abir Hassan Sarker
Mohammad Abir Hassan Sarker 2018년 4월 9일
I'm using R2018a, it's working fine in my PC, but whenever I try to submit for Cody problems, the problem I mentioned earlier occurs

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by