0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DNCLでフィボナッチ数列を求める

0
Posted at

はじめに

この記事は 共通テスト手順記述標準言語 (DNCL) Advent Calendar 2025 の18日目の記事です。

DNCLでフィボナッチ数列を求めていきます。

フィボナッチ数列とは

フィボナッチ数列とは次のような数列です。

\{1, 1, 2, 3, 5, 8, 13, 21, ・・・・・・\}

前2つの数字の和が次の数字になるという特徴があります。
松ぼっくり、貝殻の渦巻き(螺旋)、花びらの枚数(3, 5, 8, 13枚など)など、自然界の様々な植物や動物の形態、成長パターンに現れる不思議な数列です。

フィボナッチ数列は次の漸化式で表されます。

\begin{cases}
F_1 = 1, \\[2mm]
F_2 = 1, \\[1mm]
F_n = F_{n-1} + F_{n-2}, & ( n \ge 3 )
\end{cases}

フィボナッチ数列を求める

kazu個のフィボナッチ数を新しく求め、配列f(添え字は1から始まる)に追加していきます。

f ← {1,1}
kosu ← 2
kazu ← 100
i を1から kazu まで1ずつ増やしながら
|  f[kosu + 1] ← f[kosu - 1] + f[kosu]
|  kosu ← kosu + 1
を繰り返す
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?