diff options
| author | mokha <mokha@cisco.com> | 2019-05-08 19:20:31 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-08 19:20:31 -0600 |
| commit | 45cc3ed51321f3a735ceed7e3394ee3e6ab16af1 (patch) | |
| tree | cee4e78bc52a57e51a448ac237c372397ca38f46 /src/Q7 | |
| parent | 24f849e76ac46ef2a08c3904cecb195e4f7f85af (diff) | |
start program profile for each question
Diffstat (limited to 'src/Q7')
| -rw-r--r-- | src/Q7/README.md | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Q7/README.md b/src/Q7/README.md new file mode 100644 index 0000000..8f79356 --- /dev/null +++ b/src/Q7/README.md @@ -0,0 +1,64 @@ +Learning Profile for Assignment #1, And Question #7 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +Douglas Hofstadter’s Pulitzer-prize-winning book Gödel, Escher, Bach contains many interesting mathematical puzzles. + +In Chapter XII, Hofstadter mentions a wonderful problem that is well within the scope of the control statements in Java. + +The problem can be expressed as follows: + +* Pick some positive integer and call it n. +* If n is even, divide it by two. +* If n is odd, multiply it by three and add one. +Continue this process until n is equal to 1. + +Hofstadter illustrates this process with the following example, +starting with the number n = 15: +15 is odd, so I make 3n+1: 46 +46 is even, so I take half: 23 +23 is odd, so I make 3n+1: 70 +70 is even, so I take half: 35 +35 is odd, so I make 3n+1: 106 +106 is even, so I take half: 53 +53 is odd, so I make 3n+1: 160 +160 is even, so I take half: 80 +80 is even, so I take half: 40 +40 is even, so I take half: 20 +20 is even, so I take half: 10 +10 is even, so I take half: 5 +5 is odd, so I make 3n+1: 16 +16 is even, so I take half: 8 +8 is even, so I take half: 4 +4 is even, so I take half: 2 +2 is even, so I take half: 1 + +As you can see from this example, the numbers go up and down, but eventually—at least for all numbers that have ever been tried—come down to end in 1. +In some respects, this process is reminiscent of the formation of hailstones, +which get carried upward by the winds over and over again before they finally descend to the ground. +Because of this analogy, this sequence of numbers is usually called the Hailstone sequence, +although it goes by many other names as well. + +Write a program that reads in a number from the user and then displays the Hailstone sequence for that number, +followed by a line showing the number of steps taken to reach 1. + + +2. Description of the Code: + +[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] + +3. Errors and Warnings: + +[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] +Table 1: List of Errors and Warnings Encountered in the Program + + +4. Sample Input and Output: +[Provide some test cases with sample input and output of your program.] + +5. Discussion: + +[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] |
