function n = collatz(n)
    n = uint16(n);
    while n > 1
        disp(n);
        if mod(n,2) == 0
            n=n/2;
        else
            n=3*n+1;
        end
    end
end

