Files
freeCodeCamp/curriculum/challenges/japanese/10-coding-interview-prep/project-euler/problem-230-fibonacci-words.md
2022-04-02 17:46:30 +09:00

2.1 KiB
Raw Permalink Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f4531000cf542c50ff65 問題 230: フィボナッチ文字列 5 301874 problem-230-fibonacci-words

--description--

任意の 2 つの数字列 AB について、前の2項をつなげた項からなる数列 (A, B, AB, BAB, ABBAB, \ldots) を F_{A,B} とします。

また、F_{A,B} の中で n 桁以上から成る最初の項の n 番目の桁を、D_{A,B}(n) と定義します。

例:

A = 1\\,415\\,926\\,535, B = 8\\,979\\,323\\,846 とします。 ここで、例えば D_{A,B}(35) を求めたいとします。

$F_{A,B} の最初のいくつかの項は次のとおりです。

$$\begin{align} & 1\,415\,926\,535 \\ & 8\,979\,323\,846 \\ & 14\,159\,265\,358\,979\,323\,846 \\ & 897\,932\,384\,614\,159\,265\,358\,979\,323\,846 \\ & 14\,159\,265\,358\,979\,323\,846\,897\,932\,384\,614\,15\color{red}{9}\,265\,358\,979\,323\,846 \end{align}$$

次に、D_{A,B}(35) は第 5 項の {35} 桁目であり、それは 9 です。

ここで、π の小数第 100 位までを A とします。

$$\begin{align} & 14\,159\,265\,358\,979\,323\,846\,264\,338\,327\,950\,288\,419\,716\,939\,937\,510 \\ & 58\,209\,749\,445\,923\,078\,164\,062\,862\,089\,986\,280\,348\,253\,421\,170\,679 \end{align}$$

そして、次の 100 桁を B とします。

$$\begin{align} & 82\,148\,086\,513\,282\,306\,647\,093\,844\,609\,550\,582\,231\,725\,359\,408\,128 \\ & 48\,111\,745\,028\,410\,270\,193\,852\,110\,555\,964\,462\,294\,895\,493\,038\,196 \end{align}$$

\sum_{n = 0, 1, \ldots, 17} {10}^n × D_{A,B}((127 + 19n) × 7^n) を求めなさい。

--hints--

fibonacciWords()850481152593119200 を返す必要があります。

assert.strictEqual(fibonacciWords(), 850481152593119200);

--seed--

--seed-contents--

function fibonacciWords() {

  return true;
}

fibonacciWords();

--solutions--

// solution required