how do you display the output of a while loop as an array.
code:
function [] = hailstone_sequence(n)n = input('Value for n: ');h = 1;while(n~=1)if n==1returnelseif mod(n,2) n=3*n +1elsen=n/2endh=h+1;end
if statementloopmatlab functionwhile loop
function [] = hailstone_sequence(n)n = input('Value for n: ');h = 1;while(n~=1)if n==1returnelseif mod(n,2) n=3*n +1elsen=n/2endh=h+1;end
Best Answer