Question: Write a program Using Mathematica that plots the iteration counts for each number from 1 to a few thousand (of your choice). Some number high

Write a program "Using Mathematica"

that plots the iteration counts for each number from 1 to a few thousand (of your choice). Some number high enough that it doesn't take forever to run but so that you get something interesting.

Begin by writing a while loop that plays the game for a single number. Once this code works, use a For loop to make your program run this while loop a number of times.

You can find the rules here: https://en.wikipedia.org/wiki/Collatz_conjecture

The final structure of the program should look something like this:

list = {};

For[i = 1, i <= 1000, ++i, n = i; count = 0;

Play the Collatz game starting with n, counting the number of steps it takes to finish, use a while loop

append count to list ];

ListPlot[list];

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!