Files
gikf 1af6e7aa5a fix(curriculum): clean-up Project Euler 321-340 (#42988)
* fix: clean-up Project Euler 321-340

* fix: typo

* fix: corrections from review

Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>

* fix: corrections from review

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>

Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2021-07-29 11:59:06 -07:00

1011 B

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f4b21000cf542c50ffc5 Problem 326: Modulo Summations 5 301983 problem-326-modulo-summations

--description--

Let an be a sequence recursively defined by: a_1 = 1, \displaystyle a_n = \left(\sum_{k = 1}^{n - 1} k \times a_k\right)\bmod n.

So the first 10 elements of a_n are: 1, 1, 0, 3, 0, 3, 5, 4, 1, 9.

Let f(N, M) represent the number of pairs (p, q) such that:

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

It can be seen that f(10, 10) = 4 with the pairs (3,3), (5,5), (7,9) and (9,10).

You are also given that f({10}^4, {10}^3) = 97\\,158.

Find f({10}^{12}, {10}^6).

--hints--

moduloSummations() should return 1966666166408794400.

assert.strictEqual(moduloSummations(), 1966666166408794400);

--seed--

--seed-contents--

function moduloSummations() {

  return true;
}

moduloSummations();

--solutions--

// solution required