Start

2022-01-11 04:00 AKST

LTAI-22-01-16

End

2022-01-16 09:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -134 days 6:14:04

Time elapsed

125:00:00

Time remaining

0:00:00

Problem J
Low Order Zeros

When you compute a large, factorial number, it has a long string of low-order zeros at the end. This makes sense; every time you multiply in something like a $10$ or a $20$, you are sure to pick up another low-order zero. Thus, it’s easy to guess the low-order digit of something like $3\, 249!$. It’s a little harder to guess what the lowest-order non-zero digit will be. Write a program to do that.

Input

Input consists of up to $1\, 000$ test cases, one per line. Each test case is a single positive integer $i \le 10^6$. Input ends with a value of zero.

Output

For each test case, print out the value of the rightmost (lowest-order) non-zero digit of $i!$.

Sample Input 1 Sample Output 1
3
25
492
0
6
4
8