Question: . Consider a positive integer X. Multiplying its non-zero digits pro- duces another integer Y. Repeating this process, we eventually ar- rive at a single
. Consider a positive integer X. Multiplying its non-zero digits pro- duces another integer Y. Repeating this process, we eventually ar- rive at a single digit between 1 and 9. Write a program called product_061.py that reads X from stdin and outputs the digit that results from applying the above process. You can assume X is in the range 1-10000. In this example, we start with 707. Repeatedly multiplying the non- zero digits we get 7 x 7 = 49,4 x 9 = 36, 3 x 6 = 18, and 1 x 8 = 8. We are done since 8 is in the range 1-9 and we output 8. $ cat product_stdin_00_061.txt 707 $ python3 product_061.py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
