Question: Write program in C language using loops. The Collatz Conjecture is a problem in mathematics that has the following simple state- ment. Take any positive

 Write program in C language using loops. The Collatz Conjecture is

Write program in C language using loops.

The Collatz Conjecture is a problem in mathematics that has the following simple state- ment. Take any positive integer n. If n is even, divide it by 2 to get . If it is odd, multiply it by three and add one to get 3n +1. Repeat this process until you get to 1 (this process is known as HOTPO, Half Or Triple Plus One). The conjecture states that for any positive integer n, you will always eventually end up at 1. So far, no proof is known for this conjecture Write a program that tests this conjecture for a given positive integer. That is, write a program that reads a positive integer n as a command line argument, then executes the HOTPO procedure until it reaches 1. Your program should output the sequence of operations as well as the number of iterations it took to converge to the value 1 Your program output may look something like the following. 1 Input n: 42 242 / 2=21 33*21 +1-64 4 64 / 2=32 s 32 2-16 6 16 / 2=8 78/2=4 s 4 2 2 92/2=1 10 Collatz Number for n = 42 is 8

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!