- #1
TylerH
- 729
- 0
How do I plot (x, collatz(x)), where x in an integer between 1 and 1000 inclusive, on a scatter plot?
Code:
function c = collatz(n)
c = 0;
while(n != 1)
if(mod(n,2) == 0)
n /= 2;
else
n = 3 * n + 1;
end
c++;
end
end