Question: multiplying 0 and 9 results in 0 adding 5 results in 5 dividing by 8 and taking the remainder leads to 5 . Since each
multiplying and results in
adding results in
dividing by and taking the remainder leads to
Since each number generated determines the next one, once the next number is the seed, the sequence
will start repeating itself.
Write a program that, given a nonnegative integer seed, prints one by one a pseudorandom sequence
of integers using the computation described above, and stops when the seed is printed again. The result
for the example sequence is shown below.
The answer box contains Pattern Sequence generation as comments, to get you started. Write the
corresponding code beneath each comment. Use variable names appropriate to the problem at hand
instead of the generic names used by the pattern. Use the getinput operation to get the seed
number. This operation has already been predefined. Use the following statement in your code: seed
getinput
You will have to modify the pattern slightly to obtain the expected behaviour.
Think which input values are admissible, ie won't lead to an infinite loop, and put that in your code's
documentation.
For example:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
