The program takes a number (n) and processes it through the
while
loop. It is complete when the value of
n
reaches 1.the program would normally print out the value it started with and the length of the sequence of numbers it went through to reach 1. In other words, it takes one value for
n
and processes it, producing a series (or sequence) of numbers.
For example, using the supplied program, output using the start value of 51 would look like:
The sequence starting at 51 has length 25
What You Must Do
Test all possible input values between 1 and 500,000 (including those two values).
You are looking for two sequences:
- one with the longest sequence of numbers of any of the sequences, and
- one with the highest value reached of any value in any of the sequences.
- At end of the program, with appropriate messages, show:
- the starting value and the length (number of values) of the longest sequence in the series, and
- the starting value of the sequence with the highest value reached in the series with the high value itself.
The final output will look something like this:
The longest sequence starts at 27 and has length 44
The highest value sequence starts at 53 and has the high value 100
The values shown here are for demonstration only and are not even close to the correct answers.
Do not print out the intermediate values in the series. You are to print only the two lines, with the appropriate values in them, as described above.