0%

Problem 381


Problem 381


(prime-k) factorial

For a prime p let S(p) = (∑(p-k)!) mod(p) for 1 ≤ k ≤ 5.

For example, if p=7,
(7-1)! + (7-2)! + (7-3)! + (7-4)! + (7-5)! = 6! + 5! + 4! + 3! + 2! = 720+120+24+6+2 = 872.
As 872 mod(7) = 4, S(7) = 4.

It can be verified that ∑S(p) = 480 for 5 ≤ p < 100.

Find ∑S(p) for 5 ≤ p < 108.


(素数-k)阶乘

取素数p,令S(p) = (∑(p-k)!) mod(p),其中1 ≤ k ≤ 5。

例如,如果p=7,
(7-1)! + (7-2)! + (7-3)! + (7-4)! + (7-5)! = 6! + 5! + 4! + 3! + 2! = 720+120+24+6+2 = 872。
由于872 mod(7) = 4,所以S(7) = 4。

可以验证,对于5 ≤ p < 100,∑S(p) = 480。

对于5 ≤ p < 108,求∑S(p)。