CIT 591 Assignment 2: Scott's Problem David Matuszek |

Consider the following problem, defined for positive integers:

- Choose a number.
- Repeatedly do the following:
- If the number is 1, quit, otherwise
- If the number is even, cut it in half.
- If the number is odd, multiply it by 3 and add 1.

- If the number is 1, quit, otherwise

Example: If you start with the number 17, you get the following sequence:

- 17 -- this is odd, so multiply by 3 and add 1, getting 52
- 52 -- this is even, so divide by 2, getting 26
- 26 -- this is even, so divide by 2
- 13 -- this is odd, so multiply by 3 and add 1
- 40 -- this is even
- 20 -- this is even
- 10 -- this is even
- 5 -- this is odd
- 16 -- this is even
- 8 -- this is even
- 4 -- this is even
- 2 -- this is even
- 1 -- stop

Does this procedure eventually reach 1 and stop for *every* choice of
starting number? So far, this is an unsolved problem--no one has yet proved
that the process always results in 1, and no one has yet found a counterexample.

**Your assignment: **Write an application (not an applet) that does the
following:

- Prints out your name, followed by a blank line.
- For each of the numbers 1 through 20, print out a line that begins with
the number, then a colon and space, then the sequence of numbers that results
from starting with the given number. Separate the numbers by spaces. For example,
starting from the number 17, you would print the single line:

`17: 52 26 13 40 20 10 5 16 8 4 2 1`

- For extra neatness, you can make the numbers line up better by inserting an extra space before each single-digit number (a number less than 10).