Question: C++ Consider the Collatz sequence: a_i + 1 = {a_i / 2 for a_i even 3a_i + 1 for a_i odd It is conjectured that

C++
Consider the Collatz sequence: a_i + 1 = {a_i / 2 for a_i even 3a_i + 1 for a_i odd It is conjectured that for any positive integer n = a_0. the Collatz sequence will eventually reach 1. That is, Forall_n > 0 i greaterthanorequalto 0: a_0 = n a_i = 1. The smallest i for which a_i, = 1 given a_0 = n is called the stopping time of n. For the following, use whatever programming language you'd like. Submit a printout of your code along with the generated results. Write a non-recursive (iterative) function that takes an integer input n and returns the stopping time of n. What is the stopping time of n = 209? Write a recursive function that takes an integer input n and returns the stopping time of n. What is the stopping time of n = 1337? Generate a properly labeled dot plot of the stopping time for numbers 1 to 1000. What number in that range generates the longest Collatz sequence
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
