[Tutor] python

Krish P krishp52 at rocketmail.com
Sun Jun 14 08:09:30 EDT 2020


The Syracuse (also called the Collatz Hailstone) sequence is generated by starting with anatural number and repeatedly applying the following function:𝑠𝑦𝑟(𝑥) = 􀵜𝑥/2, 𝑖𝑓 𝑥 𝑖𝑠 𝑒𝑣𝑒𝑛3𝑥 + 1, 𝑖𝑓 𝑥 𝑖𝑠 𝑜𝑑𝑑For example the Syracuse sequence starting with number 5 is: 5,16,8,4,2,1. This is an openquestion in mathematics whether this sequence will always go to 1 for every possible startingvalue.
Problem to be SolvedYou will find a data file on Moodle alongside your assignment specifications called “data.txt”.This data file contains natural numbers, one on each line.1. Your role as a programmer is to create a program that will read all this data from the fileand generate the Syracuse sequence for each of those numbers.2. Additionally, you have to write every one of these Syracuse sequences into a file calledSyra.txt using your code.
data.txt:5171489041560302625118640372871807577663267444425332206991424075339339242048076287520376042156789972989546896669773172194641692345396892524370564098552375921179116691885394649252421723842536911736




More information about the Tutor mailing list