In this lab we will try to gain a bit more information about the 3n+1 sequence. We will start with the code from the chapter and make modifications. Here is the function so far.
def seq3np1(n):""" Print the 3n+1 sequence from n, terminating when it reaches 1."""
while n != 1: print(n)
if n % 2 == 0: # n is even
n = n // 2
else: # n is odd
n = n * 3 + 1
print(n) # the last print is 1
​seq3np1(3)
Repeat the call to seq3np1 using a range of values, up to and including an upper bound.
Now that we have a function that can return the number of iterations required to get to 1, we can use it to check a wide range of starting values. In fact, instead of just doing one value at a time, we can call the function iteratively, each time passing in a new value. Create a simple for loop using a loop variable called start that provides values from 1 up to 50. Call the seq3np1 function once for each value of start. Modify the print statement to also print the value of start.