070802 - What is the last digit of Sum?

題目敘述 Problems Description:

輸入一個整數N(1 ≤ N ≤ 2 ∗ 10^100),請計算:

S = 1^1 + 2^2 +3^3 + … + N^N

請將S的最後一位數字進行輸出。

Give you a integer number N (1 ≤ N ≤ 2 ∗ 10^100). Please compute:

S = 1^1 + 2^2 + 3^3 + . . . + N^N

Give the last digit of S to me.

輸入說明 Input Description:

輸入包含數個N,每一行輸入一個N,當N=0時結束。

Input file consists of several N’s, each N a line. It is ended with N = 0.

輸出說明 Output Description:

每一個N的輸出結果都只有一個數字,該數字為S的最後一位數字。

For each N give a line containing only one digit, which is the last digit of S.

輸入範例 Input Example:

1

2

3

0

輸出範例 Output Example:

1

5

2

最后更新于

这有帮助吗?