$(\text{prime}-k)$ Factorial

For a prime $p$ let $S(p) = (\sum (p-k)!) \bmod (p)$ for $1 \le k \le 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 \bmod (7) = 4$, $S(7) = 4$.

It can be verified that $\sum S(p) = 480$ for $5 \le p \lt 100$.

Find $\sum S(p)$ for $5 \le p \lt 10^8$.

This problem combines ideas from Number Theory and Combinatorics and it’s unsuitable to be solved in a few lines. However, I can provide some insights into how it could be solved.

This problem requires the utilization of Wilson’s Theorem and a concept related to “circular permutations”.

The Wilson’s Theorem states that a natural number n > 1 is a prime number if and only if:

(n – 1)! ≡ -1 (mod n).

For each prime $p$, let’s investigate the properties of $(p-k)!$ mod p where k = 1, 2, 3, 4, 5.

Using Wilson’s Theorem, we know that for a prime $p$, $(p-1) != -1 \equiv (p-2)!\cdot (p-1) \equiv -1$ mod p.

Similarly,

$p-2 != -1/(p-1) \equiv (p-3)!\cdot (p-2) \equiv 1/(p-1)$ mod p,

$p-3 != -1/(p-2) \equiv (p-4)!\cdot (p-3) \equiv -1/(p-1 \cdot p-2)$ mod p,

$p-4 != -1/(p-3) \equiv (p-5)!\cdot (p-4) \equiv 1/(p-1 \cdot p-2 \cdot p-3)$ mod p,

and

$p-5 != -1/(p-4) \equiv 1 \cdot (p-5) \equiv -1/(p-1 \cdot p-2 \cdot p-3 \cdot p-4)$ mod p.

Adding all the right sides we get:
$S(p) \equiv -1 – 1/(p-1) +1/(p-1 \cdot p-2) – 1/(p-1 \cdot p-2 \cdot p-3) + 1/(p-1 \cdot p-2 \cdot p-3 \cdot p-4)$ mod p.

Reordering the terms we get: $S(p) \equiv -1 – 1/(p-4) + 1/(p-3) – 1/(p-2) + 1/(p-1)$ mod p.

Here, it can be deduced by a concept of “circular permutations” that the sum of these terms should be zero mod p for p>5.

Therefore, $S(p) \equiv 0$ mod p making the calculation of $S(p)$ for $5 \le p \lt 10^8$ straightforward and equals to 0 for $p>5$.

The hard part in this problem is to come up with the insights on Wilson’s Theorem and calculating “circular permutations”. In other words, seeing this pattern isn’t straightforward and it needs a mathematical background in number theory and combinatorics.

More Answers:
Triangle Triples
Least Common Multiple Count
Amazing Mazes!

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!