Question: Consider the sequence: 2 , 1 8 , 1 6 2 , 1 4 5 8 , 1 3 1 2 2 , 1 1

Consider the sequence:
2,18,162,1458,13122,118098,...
Create a program that asks the user to enter two numbers X and Y, with X less than Y. Then the program displays all of the numbers in the above sequence starting with the number in the sequence in position X and ending with the number in the sequence in position Y.
For example, if the user enters 3 and 6, the program displays the numbers 162,1458,13122, and 118098.
Note:
The inputs X and Y are position numbers in the sequence, not actual numbers in the sequence. For example, X=2 means the number in the sequence in second position in the sequence (in this case 18).
The program outputs all of the numbers in the sequence in between the Xth and Yth positions in the sequence. For example, X=3 and Y=6 means the program will output all of the numbers in the sequence starting at the third position and ending at the sixth position.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!