Problem

Suppose that the first number of a sequence is x, in which x is an integer. Define a0 =...

Suppose that the first number of a sequence is x, in which x is an integer. Define a0 = x; an+1 = an/2 if an is even; an+1 = 3 × an + 1 if an is odd. Then, there exists an integer k such that ak = 1.Write a program that prompts the user to input the value of x. The program output the integer k such that ak = 1 and the numbers a0, a1, a2, . . . , ak. (For example, if x = 75, then k = 14, and the numbers a0, a1, a2, . . ., a14, respectively, are 75, 226, 113, 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1.) Test your program for the following values of x: 75, 111, 678, 732, 873, 2048, and 65535

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT