Question: 4) The Collatz. Conjecture, also known as the 3n+1 problem, is the hypothesis that i in the following algorithm will always reach the value 1:

 4) The Collatz. Conjecture, also known as the 3n+1 problem, is

4) The Collatz. Conjecture, also known as the 3n+1 problem, is the hypothesis that i in the following algorithm will always reach the value 1: 1. Let i be a positive integer 2. If i is 1, stop 3. If i is even, divide i by 2 4. Otherwise if iis odd, multiply i by 3 and add 1 5. Go to line 2 For instance, if i starts at 5, we have the sequence: 5 16 8 4 2 1 and if i is 12: 12 6 3 10 5 16 84 2 1 Mathematicians are interested in whether or not this sequence will always reach 1 (there are no known counterexamples), and in how many steps it takes to reach 1 (above, 5 takes 5 steps and 12 takes 9 steps) Write a Java method, int collatz(int i) that returns the number of steps to reach 1 on input

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!