This solution is outdated. To rescore this solution, sign in.
-
3 Comments
Edward Alborghetti
on 13 Feb 2018
how can i simplify??
Olivia Li
on 26 May 2019
Try this!:D
c=n;
while n>1
if mod(n,2)
n =3*n+1;
else
n =n/2;
end
c=[c n];
end
Gustavo Morales
on 17 Nov 2019
Thats right> construct c thru concat operator [..] instead of indexing it.
Index "i" doesn't care because it don't care the size of the sequence.
Suggested Problems
-
3343 Solvers
-
1714 Solvers
-
488 Solvers
-
Convert given decimal number to binary number.
2121 Solvers
-
9348 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!