Get while loop answer as a vector
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!