Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python Please Objective: Write a Python program that takes a positive integer, test_int, and prints the Collatz sequence starting at x. Description: A Collatz sequence
Python Please
Objective: Write a Python program that takes a positive integer, test_int, and prints the Collatz sequence starting at x. Description: A Collatz sequence is obtained by repeatedly applying this rule to the previous number x in the sequence: x = x/2 if x is even 3x+1 if x is odd. Stop when the sequence gets to number 1. Sample Inputs/Outputs: Example 1: test int = 10 Expected Output: [10, 5, 16, 8, 4, 2, 1] Example 2: test_int = 24 Expected Output: [24, 12, 6, 3, 10, 5, 16, 8, 4, 2, 1] 296528.1655254.qx3zqy7 LAB ACTIVITY 13.48.1: Collatz (Loops - Medium) 0/11 main.py Load default template... 1 test_int = int(input) 2 3 #Using the value in test_int, write your code below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started