#P2529. [SHOI2001] 击鼓传花
[SHOI2001] 击鼓传花
Description
HC (Happy Child) and classmates often play a game called "passing the flower" in the classroom. The rule is that the child who gets the flower for the -th time must say the last non-zero digit of . The game proceeds in cycles, and anyone who answers incorrectly has to sing a song as a penalty.
After a few rounds, HC believed that one could simply multiply the previous child's number by and then say the last non-zero digit of the resulting number. Unfortunately, when it was HC's turn at , HC answered and was penalized, while the correct answer should have been .
HC does not want this to happen again, so you are asked to write a program that computes the last non-zero digit of .
Input Format
There are lines of input. The -th () line contains an ().
Output Format
Output lines.
The -th line should be the last non-zero digit of the factorial of the on the -th input line.
11
12
13
14
15
8
6
8
2
8
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号