Question: Question 1 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: if n is even n/2,

Question 1 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: if n is even n/2, 3x + if wis odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, the sequences for various values of n are given below. n The sequence 2 2 1 33 10 5 16 8 4 2 1 5 5 16 8 4 2 1 6 6 3 10 5 16 8 4 2 1 7 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 99 28 14 7 22 1 34 17 52 26 13 40 20 10 5 16 84 2 1 Write a C program, p1.c, using the fork() system call that generates the sequence of the Collatz conjecture in the child process. The number n will be provided in the command line, where 1 s n s 9. For example, if n-8 is provided, the numbers 8, 4, 2,1 in the Collatz sequence will be output by the child process. The child process will output the sequence by calling the uer defined function Collatz(). The parent must invoke the wait() system call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a positive number is passed on the command line. Question 1 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: if n is even n/2, 3x + if wis odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, the sequences for various values of n are given below. n The sequence 2 2 1 33 10 5 16 8 4 2 1 5 5 16 8 4 2 1 6 6 3 10 5 16 8 4 2 1 7 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 99 28 14 7 22 1 34 17 52 26 13 40 20 10 5 16 84 2 1 Write a C program, p1.c, using the fork() system call that generates the sequence of the Collatz conjecture in the child process. The number n will be provided in the command line, where 1 s n s 9. For example, if n-8 is provided, the numbers 8, 4, 2,1 in the Collatz sequence will be output by the child process. The child process will output the sequence by calling the uer defined function Collatz(). The parent must invoke the wait() system call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a positive number is passed on the command line
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
