Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Holy fuck.

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)

Name: Anonymous 2013-01-18 6:44

>>23 see #17

>>16 plus that would be a far worse solution for the problem... 'cargo-cult' style i think they call it

...this is a little cleaner, but don't use it ;)

nterms = 0;
while (nterms<=0)
    nterms=input('Enter the number of Fibonacci numbers to display:');
end;
f = [0,1];
for x=(3:nterms)
    f(x)=f(x-2)+f(x-1);
end
disp(f(1:nterms))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List