How do you form a while function using a function file and then using the function file to form a sequence by performing this operation?
1 次查看(过去 30 天)
显示 更早的评论
How do you form a while function using a function file and then using the function file to form a sequence by performing this operation?
I have this function:
function[v]=collatz(n)
%remainder is 0 when even number is divided by 2
if rem(n,2)==0
v=n/2;
else
v=3*n+1;
end
end
and I need to use a while function to find out the values for if n starts at n=9 and ends at n=1. How do I do this?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!