Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB Code Please Pick a number, any number (actually, make it a positive integer). Now, let's play a game. If your number is even, divide
MATLAB Code Please
Pick a number, any number (actually, make it a positive integer). Now, let's play a game. If your number is even, divide it by 2. If it is odd, multiply it by 3 and add 1. Repeat this process with your new number. Repeat over and over again. Lothar Collatz in 1937 guessed that this process will always eventually end at the number 1. This is now known as the Collatz conjecture. Write MATLAB code that will start with a positive integer and run through this process until a 1 is reached. Have your code print to the screen the number of iterations necessary to reach 1. As a test, your code should report that 68 iterations are necessary if we start with the number 2017. How many iterations are needed if we start with the following numbers? (a) 26 (b) 27 (Why does 27 take so much longer than 26 and 28? Just one of those things.) (c) 28 (d) 670,617,279 (this is the longest the process takes for any starting number less than 1 billion)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started