Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions