Question: Problem: The Collatz sequence in Mathematics is a sequence of positive numbers that starts from a given integer, and the next term in the sequence

 Problem: The Collatz sequence in Mathematics is a sequence of positive

Problem: The Collatz sequence in Mathematics is a sequence of positive numbers that starts from a given integer, and the next term in the sequence is created using the current term following the rule: Tnext = Tcurrent/2, if current is even, and Tnext = 3T current + 1, if Tcurrent is odd It is coniected that all Collatz sequence end at 1 if the rule is continuously applied on a starting number. For example, if the starting number is 17, then the sequence is: 17,52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 Another example: if starting number is 12, then the sequence is: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1 Coding: Write a C code using fork() system call that generates this sequence in the child process. Since the parent and child processes have their own data copy, it is important to get the initial number from the user in the child process only. The child process is also responsible to display the output. During this whole time (until child displays the final output), the parent process should wait for the child process to complete. Requirements: The following must be ensured and displayed through the program output Parent pid and child pid Indicate when parent starting and ending Indicate when child starts and ends Prompt user (with appropriate message) to enter a choice of positive integer (perform necessary error checking to ensure that a positive integer is entered) v) Display the entire sequence starting from the user entered positive integer s 33 [Hint: You can use scanf() function in C to read the input. Its syntax is: scanf("%d", &n); where n is the integer variable used for storing the user input.]

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!