subject

The Simplest Impossible Math Problem

In this problem, you are going to program a sequence of steps for a mathematical conjecture whose proof has eluded mathematicians for almost a century.

Here is the procedure:

pick a number X
repeat until X equals 1:
if the number is even, divide it by 2
if the number is odd, multiply it by 3 and add 1
The claim is that this procedure will always converge regardless of the initial value of X.

Your task is to prove this conjecture… just kidding! Your task is to program this procedure using a command line argument as input. For example, if your script is called main. py, you can assume we called your script with python main. py X where X is the input positive integer. Specifically, fill in the code for the converge(n) function which implements this procedure. It received a positive integer n, and returns the number of iterations the procedure took to complete. Also fill out the code under if __name__ == "__main__": to retrieve the first command line argument and print out text to match the following format:

With an input of X we converged to 1 after Y iterations.

where X is the input to the program and Y is the number of iterations it took to converge to 1. You can see most test cases but we've hidden a couple from you.

Given Code:

import sys

# conjecture() take a positive integer n and returns the number of executions of the loop
def conjecture(n):

if __name__ == "__main__":
# retrieve the input, it is passed as the first argument when calling the script
n =
# conjecture takes a positive integer n as input and returns
# the number of loop iterations the loop took to converge
print("With an input of",,"we converged to 1 after",,"iterations.") # fill this in!

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:30
Someone wishes to run the software on another computer system that runs an operating system that does not support the software what can he do
Answers: 3
question
Computers and Technology, 22.06.2019 19:00
Which parts of a presentation should be the most general? a. introduction and conclusion b. introduction and outline c. outline and conclusion d. outline and body
Answers: 1
question
Computers and Technology, 23.06.2019 12:20
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
You know the right answer?
The Simplest Impossible Math Problem

In this problem, you are going to program a sequenc...
Questions
question
Mathematics, 31.08.2021 17:20
question
Mathematics, 31.08.2021 17:20
question
Business, 31.08.2021 17:20
question
Biology, 31.08.2021 17:20
Questions on the website: 13722360