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 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
Heres a Python script that includes the functions described in your question along with code for plo... View full answer
Get step-by-step solutions from verified subject matter experts
