Get while loop answer as a vector
Mostra commenti meno recenti
While loop code is below. The answer I get for n=6 is n=6, n=3, n=10, etc. However, I want those answers to be listed as a vector so I can get its length. Thank you
while n>1
if mod(n,2)==0
n=n/2
else
n=3*n+1
end
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!