close all; clear; clc

num_values = 5;
x = zeros(num_values, 1);
x(1) = 8;
for i = 2:num_values
    if mod(x(i-1), 2) == 0
        x(i) = x(i-1) / 2;
    else
        x(i) = 3 * x(i-1) + 1;
    end
    if x(i) == 1
        break
    end
end
disp(x)