Name: Lauren yo. 2013-01-18 5:15
It's come to this point. I've been trying to create a program in MATLAB for hours now that will calculate Fibonacci's sequence to 20 numbers (I'm just going with nterms=input('Number of terms.')
But anyway...I'm fucked. I have class at 1:35, not to mention a lab report for this class that I've yet to finish. Plus a shitton of other programming also due. Any help at this ungodly hour would be really appreciated.
Btw, this is what I have so far:
x=0;
nterms=input('Enter the number of Fibonacci numbers to display: ');
if nterms<=0
disp('Error: Input must be a positive integer.')
end
for f=(1:nterms)
while x<=nterms
f(1)=0;
f(2)=1;
if nterms<2&&nterms>0
disp(f(1))
end
if nterms>1&&nterms<3
disp(f(1:2))
end
x=3;
f(x)=f(x-2)+f(x-1);
x=x+1;
end
end
disp(f)
But anyway...I'm fucked. I have class at 1:35, not to mention a lab report for this class that I've yet to finish. Plus a shitton of other programming also due. Any help at this ungodly hour would be really appreciated.
Btw, this is what I have so far:
x=0;
nterms=input('Enter the number of Fibonacci numbers to display: ');
if nterms<=0
disp('Error: Input must be a positive integer.')
end
for f=(1:nterms)
while x<=nterms
f(1)=0;
f(2)=1;
if nterms<2&&nterms>0
disp(f(1))
end
if nterms>1&&nterms<3
disp(f(1:2))
end
x=3;
f(x)=f(x-2)+f(x-1);
x=x+1;
end
end
disp(f)