14706 - Digit rotation   

Description

Write a program that repeatedly transforms a given integer as follows:

  • Take the last digit of the number and move it to the front.

  • If the last digit is 0, it becomes the first digit but is discarded.

For example:

  • 1234 → 4123

  • 1230 → 123

  • 1100100 → 110010 → 11001 → 11100 → 1110 → 111

The input contains two integers:

  • the initial number,

  • the number of times to perform the transformation.

Output the sequence starting from the original number, printing each intermediate result after every transformation.

(Hint

  • You may need to use a for-loop to repeat the process.

  • You may need to use / and % to separate the last digit and the remaining digits.

)

Input

Two integers: the number and the number of transformations.

Output

Print the number after each transformation step, starting with the original number.

Ensure that the output, including formatting, exactly matches the provided samples.

Sample Input  Download

Sample Output  Download

Tags

11410EE 231002



Discuss