Question: How do you write a python code for this? n2 1and the following rules: . If n is even, the next number is n/2 o

 How do you write a python code for this? n2 1and
How do you write a python code for this?

n2 1and the following rules: . If n is even, the next number is n/2 o If n is odd, the next number is 3n+1 If n 1, the sequence stops. These rules are repeated until the sequence hits 1. For example, the Syracuse sequence starting at 3 is [3, 10, 5, 16,8, 4,2,1. Write a function according to the following specification: Behavior Parameters n: int Precondition n is greater than or equal to 1 Computes the Syracuse sequence starting at a certain point the starting point of the sequence Return list of ints Values the list of numbers in the Syracuse sequence starting at n Input:n 3 Input:n 1 Test Cases Output: (3, 10, 5, 16, 8,4,2, Output:( 1]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!