At my University we have been set the task of creating the Collatz Conjecture on Matlab. Where you take a positive integer and if the number is odd multiply it by 3 and add 1, if it is even divide it by two. Apply the same rule to the number you just generated and keep repeating the rule until you eventually reach 1. Here is the question:
1. "given an integer, n, as an input, generates the Collatz sequence for n, terminating when (if) the sequence reaches 1. It should then print the sequence to the screen along with the length of the sequence and the highest number to appear in the sequence. "
If there is anyone out there who can help it would be much appreciated.
0 · ·