Question: Instructions Write a C++ program that repeatedly does the following. Input a positive integer from the user and print the Collatz sequence starting at that

Instructions Write a C++ program that repeatedly does the following. Input a positive integer from the user and print the Collatz sequence starting at that integer, with items separated by blanks and followed by a newline. For example, if the user types 3, then the program should print 3 10 5 16 8 4 2 1 If the user types 2, then the program should print 2 1 If the user types 1, then the program should print 1 If the user types 60, then the program should print 60 30 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 The source code for your program should be contained in a single file named collatz.cpp. The program should check whether the number the user types is positive. If it is not, the program should notify the user and give an opportunity to redo the input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!