%斐波那契数列
clear;clc;
a=zeros(1,20);
a(1,1)=0;a(1,2)=1;
for k=3:20
a(1,k)=a(1,k-2)+a(k-1);
end
disp(a);
结果: columns 1 through 8
0 1 1 2 3 5 8 13
columns 9 through 16
21 34 55 89 144 233 377 610
columns 17 through 20
987 1597 2584 4181
2.没看懂题意。matlab,给x赋值,就能求出e^x
3.%jc为阶乘,bk=3.5时,跳出循环
while(1)
sum=1;
n=input('请输入一非负整数:');
bk=input('输入bk:');
if bk==3.5
break;
elseif n<0
disp('error!')
elseif n==0
jc=1;
else
for i=1:n
sum=sum*i;
end
jc=sum;
disp(jc);
end
end