The Syracuse sequence for an integer is defined as follows: For any integer n less than 1, it is an empty sequence. For n = 1, the sequence is simply 1. For any integer n greater than 1, we use the formula

[tex]syr(n) = \left \{ {{n/2\ if\ n\ is\ even,} \atop {3n + 1\ if\ n\ is\ odd.}} \right.[/tex]

Apply the function syr repeatedly until you reach 1. For example, the Syracuse sequence for 10 is

10, 5, 16, 8, 4, 2, 1.

Write a function syracuse that takes an integer as an input and returns a string representing its Syracuse sequence.

Note: The program has to be written in the Python programming language!



Answer :