Question
Investigate what value of n between 1 and an input value (such as 100,000) gives the longest sequence, and how long that sequence is. Write
Investigate what value of n between 1 and an input value (such as 100,000) gives the longest sequence, and how long that sequence is. Write a function in Python named biggest_seq(end), where end is the largest integer input. This function will evaluate different values of n, where the starting value of n should be 1 and the final value is equal to the end variable.
The aim of this function is to identify what value of n gives the longest collatz sequence. For testing, you should use your own collatz function, but for the submission, you can assume there is a fully working collatz(n) function already present.
You should return 2 variables, the sequence number and the sequence length.
test:
seqN, seqL = biggest_seq(100000)
print("Value of N = " + str(seqN))
print("Length = " + str(seqL))
results:
> Value of N = 77031
> Length = 351
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started