Question: Implement a function which will print the number and sequence length of the longest sequence length for a given range of numbers using the above
Implement a function which will print the number and sequence length of the longest sequence length for a given range of numbers using the above function (collatz_seq):

The Collatz sequence: Start with some given positive integer n. If it is even, the next number will be n divided by 2. If it is odd, multiply it by 3 and add 1 to make the next number. The sequence stops when it reaches 1. According to the Collatz conjecture, it will always reach 1. If that's true, you can construct a finite sequence following the aforementioned method for any given integer. def collatz seg(n: int): " Returns the Collatz sequence for a given integer n sequence = 0) sequence.append(n) while sequence (-1] != 1: if (sequence (-1] * 2) == 0: next = sequence[-1] / 2 else: next = sequence[-1] * 3 + 1 sequence.append(next) return sequence def print_longest sequence(start end): Implement a function which will print the number and sequence length of the Longest sequence length for a given range of numbers using the above function # your code goes here pass if __name__ == "_main_": print_longest_sequence(1, 100)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
