Files
freeCodeCamp/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-326-modulo-summations.md
2022-01-23 00:08:20 +09:00

1.1 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f4b21000cf542c50ffc5 問題 326: 剰余の総和 (Modulo Summation) 5 301983 problem-326-modulo-summations

--description--

a_1 = 1, \displaystyle a_n = \left(\sum_{k = 1}^{n - 1} k \times a_k\right)\bmod n によって再帰的に定義される数列を a_n とします。

したがって、a_n の最初の 10 項は 1, 1, 0, 3, 0, 3, 5, 4, 1, 9 です。

次の条件を満たす対 (p, q) の個数を f(N, M) とします。

1 \le p \le q \le N \\; \text{かつ} \\; \left(\sum_{i = p}^q a_i\right)\bmod M = 0

$f(10, 10) = 4 であることが分かります。(3,3), (5,5), (7,9), (9,10) の 4 対です。

さらに、f({10}^4, {10}^3) = 97\\,158 が与えられます。

f({10}^{12}, {10}^6) を求めなさい。

--hints--

moduloSummations()1966666166408794400 を返す必要があります。

assert.strictEqual(moduloSummations(), 1966666166408794400);

--seed--

--seed-contents--

function moduloSummations() {

  return true;
}

moduloSummations();

--solutions--

// solution required