#K13576. Single Digit Product Challenge
Single Digit Product Challenge
Single Digit Product Challenge
The challenge is to compute the single digit product of an integer by repeatedly multiplying its digits until a single-digit number is obtained. For a given number \( N \), you should multiply all its digits together, replace \( N \) with this product, and repeat the process until \( N \) is a single digit. If any multiplication results in 0, the process ends immediately with 0 as the final result.
Example:
- Input: 9875
- Calculation: \( 9 \times 8 \times 7 \times 5 = 2520 \); then \( 2 \times 5 \times 2 \times 0 = 0 \)
- Output: 0
This problem tests your ability to iteratively perform arithmetic operations and handle potential pitfalls like multiplication by zero. Make sure your solution reads the input from stdin and prints the output to stdout.
inputFormat
The input consists of a single line containing one non-negative integer \( N \) (\( 0 \leq N \leq 10^{18} \)).
outputFormat
Output a single integer that is the resulting single digit after repeatedly multiplying the digits of \( N \) until it becomes a single digit.
## sample9875
0