Info
此问题已关闭。 请重新打开它进行编辑或回答。
I want to make fibonacci series by this way, but there is some error in my code (I think in sum line), can someone point ?
1 次查看(过去 30 天)
显示 更早的评论
clear all
clc
n=20;
f=0;
for i=1:n
for i=1
f(i)=0;
end
for i=2
f(i)=1;
end
f(i:n)=sum(f);
end
f
1 个评论
KALYAN ACHARJYA
2019-11-18
编辑:James Tursa
2019-11-18
Please do read here array indexing
n=20;
f=zeros(1,n);
f(1)=1;
f(2)=1;
for i=3:length(f)
f(i)=f(i-2)+f(i-1);
end
f
Please note: Without understanding the code, it has no meaning in your learning, hence I requested you to modify it and see the different results.
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!