Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need to find the longest term and the biggest number Project Description / Specification Your program takes as input three integer values (same line, space
need to find the longest term and the biggest number
Project Description / Specification Your program takes as input three integer values (same line, space separated) the first two integers, the beginning and ending value in a range of integers you are going to examine, as space separated integers. They are in that order: the first is the lower range and the second is the upper range. Calculate the sequence for each value in that range inclusive of the endpoints the third integer a value indicating whether to print each sequence: 1 (indicating yes) or 0 (indicating no) * Your program will print (look at the Mimir test cases for examples) the sequence for each number in the range on a separate line if the third input value is 1 . note in printing the sequence the numbers are followed by a comma, except for the last number in the sequence. A personal pet peeve of mine. o On a separate line, two comma separated numbers. For the sequence that is the longest, print the starting number and the length of the sequence (again, see Mimir for format) . On a separate line, two comma separated numbers. For the sequence that contains the biggest number, print the starting number and the biggest number in that sequence. Requirements I. You should check that the first two input range numbers are >= 2, and that the smallest (the first entered value) is indeed strictly smaller than the second (the second value). If not, the program prints an error message and halts Notes I. The % (modulus) operator is useful for this project 2. If you ask for a large enough element, you might overflow an integer. If you go big enough, you will overflow a long (though it will take awhile) Background The juggler sequence is another of the well known sequences similar to the Collatz sequence. It has the following definition: , 1f ak 1S eVen Ck+1 3 The lI symbol is the floor function, rounding any floating point value down to an integer. It is not rounding as you would typically define it. It is essentially truncation of the fractional part, leaving the integer part of the floating point number. It returns a floating point number. floor( 123.23) s 123.0 floor(123.999) is 123.0 . * Some things to note about the juggle sequence . Every known starting number eventually ends in the value 1. At that point the sequence ends The numbers can get quite large, so make sure you use the correct tvpe, a long. Even with the correct types vou can exceed the size of a long integer. o if that occurs, you will see some strange results. Why is that? The cmath library provides a number of useful methods including pow, sqrt and floor (look them up) Debugging Informatlon for 02- 10to20 O PROGRAM EXECUTION STACK TRACE None YOUR CODE'S OUTPUT Error UNIX DIFF OF CORRECT OUTPUT AND YOUR OUTPUT 1c1, 2 rror 19 9 19 140 THE CORRECT OUTPUT OF THE TEST CASE 19 9 19 140Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started