Question: CSCI423/501 Programming Assignment 2 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: 12 if n

 CSCI423/501 Programming Assignment 2 The Collatz conjecture concerns what happens when

CSCI423/501 Programming Assignment 2 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: 12 if n is even .1if n is odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, if n-35, the sequence is 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4,2,1 Write a C program using the fork0 system call that generates this sequence in the child process. The starting number will be provided from the command line. For example, if 8 is passed as a parameter on the command line, the child process will output 8, 4, 2, 1. Have the parent invoke the wait) call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a positive integer is passed on the command line. Following are some running examples, assuming the compiled program named b.out: Example 1: ./b.out 3 3, 10, 5, 16, 8, 4, 2, 1 Example 2: 7b.out -3 Example 4: /b.out 3 10 sage: . /b.out

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!