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..
Define the modulo division operator in c language, Define the Modulo Divisi...
Define the Modulo Division Operator in c language? The C provides one more arithmetic operator % called as modulo division operator and this operator yields the remainder of an
Car rental project, I need a project on car rental system using c programmi...
I need a project on car rental system using c programming only of college level
#pointers, what is the purpose of pointer ? what is the syntax? how it work...
what is the purpose of pointer ? what is the syntax? how it works?
Force(F)= ma, Force(F)= ma
I want nike twitter rsvp bot, Project Description: Project Description: ...
Project Description: Project Description: I am seeking a programmer who will be able to design some software that will allow the user to: 1) Repeatedly monitor Nike twitter a
Flowchart.., flowchart of c programing to check the given number is prime o...
flowchart of c programing to check the given number is prime or not
Implement mini version of linux ''tar'', I need to implement a mini version...
I need to implement a mini version of linux''s ''tar'' function in C.
How the compiler arranges the several sections , Q: How the compiler arrang...
Q: How the compiler arranges the several sections in the executable image? A: The executable contained following sections: 1. Data Section (initialized data variable sec
Define order that local objects are destructed?, Define order that local ob...
Define order that local objects are destructed?
Dll, i need amibroker afl to dll plugin
i need amibroker afl to dll plugin
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
IT Courses and Help
Why Us ?
~24x7 hrs Support
~Quality of Work
~Time on Delivery
~Privacy of Work
Human Resource Management
Literature Review Writing Help
Follow Us |
T & C
Copyright by ExpertsMind IT Educational Pvt. Ltd.