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 19:20
Consider the following code snippet: #ifndef cashregister_h#define cashregister_hconst double max_balance = 6000000.0; class cashregister{public: cashregister(); cashregister(double new_balance); void set_balance(double new_balance); double get_balance() const; private: double balance[12]; }; double get_monthly_balance(cashregister bk, int month); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_balance should be removed since header files should not contain constants.c)the definition of cashregister should be removed since header files should not contain class definitions.d)the body of the get_monthly_balance function should be added to the header file.
Answers: 1
question
Computers and Technology, 23.06.2019 10:30
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
What are the 12 colors of the spectrum called?
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
You know the right answer?
The Simplest Impossible Math Problem

In this problem, you are going to program a sequenc...
Questions
question
History, 03.11.2019 02:31
question
English, 03.11.2019 02:31
Questions on the website: 13722361