Isaac H.

asked • 12/21/22

The Syracuse sequence for an integer is defined as follows: For any integer n less than 1, it is an empty sequence.

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


syr(n) = (n/2 if n is even,

(3n + 1 if n is odd.


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.

1 Expert Answer

By:

James D. answered • 12/21/22

Tutor
0 (0)

Software Engineer specialized in Python, Golang, and C.

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.