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
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
Get step-by-step solutions from verified subject matter experts
