Question: How do I convert this flowchart into python code? COMPSCI 119 LAB #1 - Converting a Flowchart into Python The following flowchart is of a
How do I convert this flowchart into python code?
COMPSCI 119 LAB #1 - Converting a Flowchart into Python The following flowchart is of a simple program that generates a list of numbers that explores the Collatz Conjecture (Lothar Collatz, 1937): start with any positive integer N, and if it is even divide it by 2 but if odd multiply it by 3 and add 1, then repeat. Eventually, says the conjecture, it will always reach 1, at which point the process stops. Surprisingly, while it always seems to work, the conjecture has never been formally proven. This is also known as the Hailstones problem, because whenever a power of 2 is encountered the sequence immediately "hails" down to 1. START Variables N INPUTN C = 0 PRINT CAN FALSE N>1? TRUE C = C + 1 FALSE Is N Odd? TRUE N = N + 2 N = 3 * N + 1 PRINT CAN STOP
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
