Files
freeCodeCamp/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-111-primes-with-runs.md
2022-01-20 20:30:18 +01:00

62 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 5900f3db1000cf542c50feee
title: '問題 111: 素数内の反復数字'
challengeType: 5
forumTopicId: 301736
dashedName: problem-111-primes-with-runs
---
# --description--
同じ数字が繰り返し使われている 4 桁の素数について考える場合、当然ながら、すべての桁が同じ数字にはなり得ません。1111 は 11 で割り切れ、22222 は 22で割り切れ、以降も同様だからです。 しかし、1 を 3 つ含む 4 桁の素数は 9 つあります。
$$1117, 1151, 1171, 1181, 1511, 1811, 2111, 4111, 8111$$
反復数字を d とし、n 桁の素数について反復数字の最大個数を $M(n, d)$ と表すことにします。また、そのような素数の個数を $N(n, d)$ と表し、これらの素数の和を $S(n, d)$ と表すことにします。
$M(4, 1) = 3 は、4 桁の素数に含まれる反復数字 1 が最大 3 個であること、$N(4, 1) = 9 は、そのような 4 桁の素数が 9 つあること、そして $S(4, 1) = 22275$ は、それらの素数の和を表します。 d = 0 のとき、$M(4, 0) = 2$ (反復数字は最大 2 つ) で、$N(4, 0) = 13$ (そのようなケースが 13 個) であることが分かります。
同様にして、4 桁の素数に対して次の結果が得られます。
| 数字 d | $M(4, d)$ | $N(4, d)$ | $S(4, d)$ |
| ---- | --------- | --------- | --------- |
| 0 | 2 | 13 | 67061 |
| 1 | 3 | 9 | 22275 |
| 2 | 3 | 1 | 2221 |
| 3 | 3 | 12 | 46214 |
| 4 | 3 | 2 | 8888 |
| 5 | 3 | 1 | 5557 |
| 6 | 3 | 1 | 6661 |
| 7 | 3 | 9 | 57863 |
| 8 | 3 | 1 | 8887 |
| 9 | 3 | 7 | 48073 |
d = 0 9 のとき、$S(4, d)$ の総和は 273700 です。 $S(10, d)$ の総和を求めなさい。
# --hints--
`primesWithRuns()``612407567715` を返す必要があります。
```js
assert.strictEqual(primesWithRuns(), 612407567715);
```
# --seed--
## --seed-contents--
```js
function primesWithRuns() {
return true;
}
primesWithRuns();
```
# --solutions--
```js
// solution required
```