题目描述
Given this sequence ..
1^(1!)+2^(2!)+3^(3!)+4^(4!)+ ..N^(N!).
Your job is to write a program such that given N any time, you have to find out the unit place digit of the sum of the above sequence.
Input
Enter the number N to calculate the unit place digit of the sum of the above sequence 1 < N < 1000. The end of file is denoted by #.
Output
You have to give the unit place digit of sum of above sequence till N.
Example
Sample Input
71
Sample Output
8
输入格式
见题面
输出格式
见题面
样例输入
71
#
样例输出
8