The Collatz conjecture concerns what happens when we take anypositive integer n and

Chapter 3, Problem 3.21

(choose chapter or problem)

The Collatz conjecture concerns what happens when we take anypositive integer n and apply the following algorithm:n = n/2, if n is even3 n + 1, if n is oddThe conjecture states that when this algorithm is continually applied,all positive integers will eventually reach 1. For example, if n = 35, thesequence is35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1Write a C program using the fork() system call that generates thissequence in the child process. The starting number will be providedfrom the command line. For example, if 8 is passed as a parameter onthe command line, the child process will output 8, 4, 2, 1. Because theparent and child processes have their own copies of the data, it will benecessary for the child to output the sequence. Have the parent invokethe wait() call to wait for the child process to complete before exitingthe program. Perform necessary error checking to ensure that a positiveinteger is passed on the command line.

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back