'Store the first N (user enters N) Fibonacci numbers in a row vector.'I know how to get user entered number of fibbonachi numbers. But I don't know how to show them in a row vector.
3 ビュー (過去 30 日間)
古いコメントを表示
Lakshan Bandara
2019 年 12 月 7 日
コメント済み: Lakshan Bandara
2019 年 12 月 7 日
clc;
clear;
close all;
N=input('Enter the number = ');
B(1)=0;
B(2)=1;
count=1;
for i=3:N
B(1,i)=B(i-2)+B(i-1);
end
disp(B)
0 件のコメント
採用された回答
JESUS DAVID ARIZA ROYETH
2019 年 12 月 7 日
clc
N=input('Enter the number = ');
B=zeros(1,N);
B(1)=0;
B(2)=1;
count=1;
for i=3:N
B(1,i)=B(i-2)+B(i-1);
end
disp(B)
3 件のコメント
JESUS DAVID ARIZA ROYETH
2019 年 12 月 7 日
yes but I get:
Enter the number = 10
0 1 1 2 3 5 8 13 21 34
in any case, to get rid of the second column use:
B(:,2)=[]
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!