How do I display the first 20 numbers of the Fibonacci sequence?
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Need a for loop that displays the first 20 numbers of the Fibonacci sequence.
Here is my code so far
a=1
i=3
for a=1:20
f(i)=f(i-1)+f(i-2);
a+1
i+1
end
disp(f)
it currently displays as the output.
function_handle with value:
@(x,y)x.^2+y.^2
0 Commenti
Risposte (1)
Sindar
il 28 Set 2020
you need to define the first two numbers manually, then start on the third
f(1) = 0;
f(2) = 1;
for a=3:20
...
Also, it's unclear what you are doing with 'i'
2 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!