I have a python programing question In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way: 1. take any non-negative and non-zero integer number and name it c0; 2. if it's even, evaluate a new c0 as c0 ÷ 2; 3. otherwise, if it's odd, evaluate a new c0 as 3 × c0 + 1; 4. if c0 ≠ 1, skip to point 2. The hypothesis says that regardless of the initial value of c0, it will always go to 1. Of course, it's an extremely complex task to use a computer in order to prove the hypothesis for any natural number (it may even need artificial intelligence), but you can use Python to check some individual numbers. Maybe you'll even find the one which would disprove the hypothesis. Write a program which reads one natural number and executes the above steps as long as c0remains different from 1(c0 != 1). Moreover, we'll add another task - we want you to count the steps needed to achieve the goal. Your code should output all the intermediate values of c0, too. Hint: the most important part of the problem is how to transform Collatz's idea into a while loop - this is the key to success. Test your code using the data we've provided Example input 15 Example output 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 steps = 17
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
Answer the following
I have a python programing question
In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way:
The hypothesis says that regardless of the initial value of c0, it will always go to 1.
Of course, it's an extremely complex task to use a computer in order to prove the hypothesis for any natural number (it may even need
Write a
Hint: the most important part of the problem is how to transform Collatz's idea into a while loop - this is the key to success.
Example input
15
Example output
46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 steps = 17..
J
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images