Back to Freecodecamp

Problem 337: Totient Stairstep Sequences

curriculum/challenges/english/blocks/project-euler-problems-301-to-400/5900f4be1000cf542c50ffd0.md

latest816 B
Original Source

--description--

Let $\{a_1, a_2, \ldots, a_n\}$ be an integer sequence of length $n$ such that:

  • $a_1 = 6$
  • for all $1 ≤ i < n$ : $φ(a_i) < φ(a_{i + 1}) < a_i < a_{i + 1}$

$φ$ denotes Euler's totient function.

Let $S(N)$ be the number of such sequences with $a_n ≤ N$.

For example, $S(10) = 4$: {6}, {6, 8}, {6, 8, 9} and {6, 10}.

We can verify that $S(100) = 482\,073\,668$ and $S(10\,000)\bmod {10}^8 = 73\,808\,307$.

Find $S(20\,000\,000)\bmod {10}^8$.

--hints--

totientStairstepSequences() should return 85068035.

js
assert.strictEqual(totientStairstepSequences(), 85068035);

--seed--

--seed-contents--

js
function totientStairstepSequences() {

  return true;
}

totientStairstepSequences();

--solutions--

js
// solution required