Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions