2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: 5900f4ea1000cf542c50fffc
|
|
|
|
challengeType: 5
|
|
|
|
title: 'Problem 381: (prime-k) factorial'
|
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id='description'>
|
|
|
|
For a prime p let S(p) = (∑(p-k)!) mod(p) for 1 ≤ k ≤ 5.
|
|
|
|
|
|
|
|
|
|
|
|
For example, if p=7,
|
2018-10-08 00:01:53 +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
|
|
|
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.
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id='instructions'>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
2018-10-04 13:37:37 +00:00
|
|
|
tests:
|
|
|
|
- text: <code>euler381()</code> should return 139602943319822.
|
2018-10-08 00:01:53 +00:00
|
|
|
testString: 'assert.strictEqual(euler381(), 139602943319822, "<code>euler381()</code> should return 139602943319822.");'
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
function euler381() {
|
|
|
|
// Good luck!
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
euler381();
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|
|
|
|
</section>
|