Customer Service Chat
Get quote & make Payment
3n+1, C/C++ Programming
Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat this process with the new value of n, terminating when n is equal to 1. For example, the following sequence is generated for n = 22:
22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
It is conjectured (but not yet proven) that this algorithm will terminate at n is equal to 1 for every integer n. The conjecture holds for integers up to at least 1,000,000.
For an input n, the cycle-length of n is the number of numbers generated up to and including the 1. In the example above, the cycle length is 16.
Write a C++ program that repeatedly prompts the user for two numbers, Start and End, and determines the maximum cycle length over all numbers between Start and End, including both endpoints. Assume all inputs are integers less than 1,000,000 and greater than 0. If a negative number is entered for the start, then the program should end immediately.
Sample Command Line Interface: (Bold Signifies User Input)
Posted Date: 7/19/2012 8:41:58 PM | Location : United States
Ask an Expert
3n+1, Assignment Help, Ask Question on 3n+1, Get Answer, Expert's Help, 3n+1 Discussions
Write discussion on 3n+1
Your posts are moderated
Write your message here..
Encryption/Decryption, I need to include files so you can understand easier...
I need to include files so you can understand easier.
.luminous jewels, Byteland county is very famous for luminous jewels. Lumin...
Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec
I want packet capture analysis, I want Packet capture analysis Project D...
I want Packet capture analysis Project Description: Need assistance in debugging some packet capture Skills required is C Programming
Recursion, #questiowrite a program to calculate e^x
#questiowrite a program to calculate e^x
Explain the default constructor and destructor, The default Constructor and...
The default Constructor and Destructor If you fail to write a constructor and destructor function, the compiler automatically supplies them for you. These functions have publi
Advance in c, create a program to populate the first array then the odd num...
create a program to populate the first array then the odd number is the second array and get the sum of the second array.
Variable, what is local and global variable?give me some example to underst...
what is local and global variable?give me some example to understand better
Answer, Write a program to find the area under the curve y = f(x) between x...
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.
Develop libcurl xml project, Develop libcurl XML project I have a Projec...
Develop libcurl XML project I have a Project using XML with C++. You will use things like LIbcurl etc....and a XML parser to finish the project. Developer must know how to use X
#title.digital clock, Write a program to print a digital clock which displa...
Write a program to print a digital clock which displays the time for 2 hours .
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
Why Us ?
~24x7 hrs Support
~Quality of Work
~Time on Delivery
~Privacy of Work
Human Resource Management
Literature Review Writing Help
Terms & Conditions
Copyright by ExpertsMind IT Educational Pvt. Ltd.