I am trying to generate a plot for the 3x+1 problem for the seed 10^310 but i am unable to get the plot? Why
% Code for 3x+1 Problem
seed = 10^309; % Starting number
x = seed; % Initialize x with the seed
trajectory = x; % Store the trajectory
tic
while x ~= 1
if mod(x, 2) == 0 % Check if x is even
x = x / 2;
else % If x is odd
x = 3 * x + 1;
end
trajectory = [trajectory, x]; % Append x to trajectory
end
toc
% Plot the trajectory
figure;
plot(trajectory, ‘-o’, ‘LineWidth’, 1, ‘MarkerSize’, 5,’MarkerFaceColor’, ‘r’);
title(‘Plot of the Collatz Sequence for positive Seed 10^310’);
xlabel(‘Step’);
ylabel(‘Value’);
grid on;% Code for 3x+1 Problem
seed = 10^309; % Starting number
x = seed; % Initialize x with the seed
trajectory = x; % Store the trajectory
tic
while x ~= 1
if mod(x, 2) == 0 % Check if x is even
x = x / 2;
else % If x is odd
x = 3 * x + 1;
end
trajectory = [trajectory, x]; % Append x to trajectory
end
toc
% Plot the trajectory
figure;
plot(trajectory, ‘-o’, ‘LineWidth’, 1, ‘MarkerSize’, 5,’MarkerFaceColor’, ‘r’);
title(‘Plot of the Collatz Sequence for positive Seed 10^310’);
xlabel(‘Step’);
ylabel(‘Value’);
grid on; % Code for 3x+1 Problem
seed = 10^309; % Starting number
x = seed; % Initialize x with the seed
trajectory = x; % Store the trajectory
tic
while x ~= 1
if mod(x, 2) == 0 % Check if x is even
x = x / 2;
else % If x is odd
x = 3 * x + 1;
end
trajectory = [trajectory, x]; % Append x to trajectory
end
toc
% Plot the trajectory
figure;
plot(trajectory, ‘-o’, ‘LineWidth’, 1, ‘MarkerSize’, 5,’MarkerFaceColor’, ‘r’);
title(‘Plot of the Collatz Sequence for positive Seed 10^310’);
xlabel(‘Step’);
ylabel(‘Value’);
grid on; collatz conjecture, 3x +1 problem MATLAB Answers — New Questions