Question: please use python to answer this question The 3n 1 algorithm generates a sequence of numbers starting with an integer n. If n is even,
please use python to answer this question
The "3n 1" algorithm generates a sequence of numbers starting with an integer n. If n is even, it is divided by 2. If n is odd, it is multiplied by 3 and 1 is added. This process is repeated with each new value of n, terminating when n For example: the following sequence of numbers will be generated for n - 22: 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 For any given input n, the cycle-length is the number of integers included (including the starting and ending integer) to reach the value of 1. In the example above, the cycle length of 22 is 16. Write a function named q20 that accepts two (2) Int values as parameters. Your q20 function should evaluate each integer using the "3n + 1" algorithm to determine which has the higher cycle-length value. Finally, the q20 function should return whichever integer has the higher cycle-length and its cycle-length value Example Input/ Output: >>2 (317, 412) (412, 90) >>> q2 (100, 200) (200, 27)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
