Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions