COMP1010 Programming_Quiz 1 | Complete Solution
- AceTutor
- Rating : 33
- Grade : A+
- Questions : 0
- Solutions : 823
- Blog : 1
- Earned : $26606.70
COMP1010 Programming_Quiz 1 Fall 2017
The Collatz Conjecture
According to Wikipedia: The Collatz conjecture is a conjecture in mathematics named after Lothar Collatz, who first proposed it in 1937. The conjecture is also known as the 3n + 1 conjecture, the Ulam conjecture (after Stanisław Ulam), Kakutani's problem (after Shizuo Kakutani), the Thwaites conjecture (after Sir Bryan Thwaites), Hasse's algorithm (after Helmut Hasse), or theSyracuse problem; [1][2] the sequence of numbers involved is referred to as the hailstone sequence or hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud),[3][4] or as wondrous numbers.
Take any natural number n. If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add
1 to obtain 3n + 1. Repeat the process (which has been called "Half Or Triple Plus One", or HOTPO[6]) indefinitely. The conjecture is that no matter what number you start with, you will always eventually reach 1. The property has also been called oneness.
Create a project called Program1. Add a C source file to the project named program1.c. Your
program should create a table of numbers providing information about the number of steps that a
particular number takes in order to reach the number 1 in the sequence described above. Your program
should create the table by first asking the user to enter a starting integer > 1 and less than 1000 (ONE
THOUSAND) and then an ending number that is greater than their starting number and less than 10000
(TEN THOUSAND). For every integer in between, and including the start and end points, your program
should compute the number of steps it takes to reach the number 1 and display it beside the original
number. A sample run with the starting point of 2 and the ending point of 99 is given below:
COMP1010 Programming_Quiz 1 Fall 2017 - Dr. Mwaura
Your program should print a maximum of 7 columns per line where each column follows the
following format rules: The first number is printed right justified in 5 spaces then a colon is printed then
the number of steps is written as a left justified number in 5 spaces. The end result is that we get columns
centered on the colon character as shown in the screenshot.
You should make use of functions to make your code easy to read.
At the top of your program you should have a comment section that follows the below format:
/***********************************************
Author: <insert your name>
Date: <insert today’s date>
Purpose: <Insert a short description of what
your program does here.>
Time Spent: <Insert how much time you spent
on the assignment here>
***********************************************/
[Solved] COMP1010 Programming_Quiz 1 | Complete Solution
- This solution is not purchased yet.
- Submitted On 04 Dec, 2017 08:28:28
- AceTutor
- Rating : 33
- Grade : A+
- Questions : 0
- Solutions : 823
- Blog : 1
- Earned : $26606.70