Question: Write a function collatzseg (n) which computes the Collatz sequence (as a Python list) given an initial value n. For example, the output of

Write a function collatzseg (n) which computes the Collatz sequence (as a Python list) given an initial value 

Write a function collatzseg (n) which computes the Collatz sequence (as a Python list) given an initial value n. For example, the output of collatzseq (5) should be [5,16,8,4,2,11 (ii) Write a function collatzcount (n) which counts the number of steps s(n) until the sequence starting at 12 reaches 1. For example, s(1) = 0 and as above s(11) = 14. (iii) Plot a graph of s(n) against n for n [1, 1000]. Use circles for markers instead of lines. (iv) What percentage of initial values n have the property that s(n)

Step by Step Solution

3.45 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python script that includes the functions described in your question along with code for plo... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!