Warning!!! this was answered already but the solutions is incorrect so i reposted it please give me the right solution please this cost me a lot since i cannot get refund on the question that was answered incorrectly.   Please do this in Python Programming and provide screenshots The output should be exact same like in the examples. If the output in the example is in 2 decimals, then it should be like that.    1h - Collatz   One of the most renowned unsolved problems in mathematics is the Collatz conjecture. The problem is stated as follows: Start out with some number n. Apply the following rule repeatedly to the number: if n is even, the next number is n/2 if n is odd, the next number is 3n + 1 This will give us a list of numbers. For example, when starting with 11 the list will be  11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 4 2 1 4 2 1 ... Once the sequence has reached 1, it will repeat 4, 2, 1 indefinitely. The conjecture is that no matter which starting number you pick, the sequence will reach 1 eventually.  This conjecture is probably correct. Using computers all numbers up to 268268 have been found to reach 1. Note that 268268 is quite a large number: it is about 40 times the number of grains of sands on earth, or 4 times the number of stars in the universe. If you can check 1 number per nanosecond, trying all 268268 numbers takes you about 10,000 (10 thousand) years.  This problem is very simple to state, but no one has proved the conjecture since Collatz stated it in 1937. There have even been mathematicians that have spent years of continued study on the conjecture, without success. Fortunately, writing a program that generates the Collatz sequence is a lot less challenging. Write a program that takes any positive integer and prints the corresponding Collatz sequence up to and including the first one. Example: Please enter a number: 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1   Put your program in collatz.py. Use the % (modulo) operator to determine if a number is odd or even.    Use print(n, end = " ") to print without a new line afterward, but with a space instead

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Warning!!! this was answered already but the solutions is incorrect so i reposted it please give me the right solution please this cost me a lot since i cannot get refund on the question that was answered incorrectly.

 

  • Please do this in Python Programming and provide screenshots
  • The output should be exact same like in the examples.
  • If the output in the example is in 2 decimals, then it should be like that. 

 

1h - Collatz

 

One of the most renowned unsolved problems in mathematics is the Collatz conjecture. The problem is stated as follows:

Start out with some number n.

Apply the following rule repeatedly to the number:

  • if n is even, the next number is n/2
  • if n is odd, the next number is 3n + 1

This will give us a list of numbers. For example, when starting with 11 the list will be 

11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 4 2 1 4 2 1 ...

Once the sequence has reached 1, it will repeat 4, 2, 1 indefinitely. The conjecture is that no matter which starting number you pick, the sequence will reach 1 eventually.

 This conjecture is probably correct. Using computers all numbers up to 268268 have been found to reach 1. Note that 268268 is quite a large number: it is about 40 times the number of grains of sands on earth, or 4 times the number of stars in the universe. If you can check 1 number per nanosecond, trying all 268268 numbers takes you about 10,000 (10 thousand) years. 

This problem is very simple to state, but no one has proved the conjecture since Collatz stated it in 1937. There have even been mathematicians that have spent years of continued study on the conjecture, without success. Fortunately, writing a program that generates the Collatz sequence is a lot less challenging.

Write a program that takes any positive integer and prints the corresponding Collatz sequence up to and including the first one.

Example:

Please enter a number: 11
34 17 52 26 13 40 20 10 5 16 8 4 2 1
 

Put your program in collatz.py. Use the % (modulo) operator to determine if a number is odd or even.   

Use print(n, end = " ") to print without a new line afterward, but with a space instead.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning