2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: 5900f4ea1000cf542c50fffc
|
|
|
|
title: 'Problem 381: (prime-k) factorial'
|
2020-11-27 18:02:05 +00:00
|
|
|
challengeType: 5
|
2019-08-05 16:17:33 +00:00
|
|
|
forumTopicId: 302045
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: problem-381-prime-k-factorial
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --description--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
For a prime $p$ let $S(p) = (\sum (p - k)!)\bmod (p)$ for $1 ≤ k ≤ 5$.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
For example, if $p = 7$,
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
$$(7 - 1)! + (7 - 2)! + (7 - 3)! + (7 - 4)! + (7 - 5)! = 6! + 5! + 4! + 3! + 2! = 720 + 120 + 24 + 6 + 2 = 872$$
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
As $872\bmod (7) = 4$, $S(7) = 4$.
|
|
|
|
|
|
|
|
It can be verified that $\sum S(p) = 480$ for $5 ≤ p < 100$.
|
|
|
|
|
|
|
|
Find $\sum S(p)$ for $5 ≤ p < {10}^8$.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --hints--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
`primeKFactorial()` should return `139602943319822`.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
```js
|
2021-07-30 14:59:29 +00:00
|
|
|
assert.strictEqual(primeKFactorial(), 139602943319822);
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --seed--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
## --seed-contents--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
2021-07-30 14:59:29 +00:00
|
|
|
function primeKFactorial() {
|
2020-09-15 16:57:40 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-30 14:59:29 +00:00
|
|
|
primeKFactorial();
|
2018-09-30 22:01:58 +00:00
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|