Tribonacci Calculator
Tribonacci数列とカスタム開始値を持つ一般化バリアントを生成します。
トリボナッチ定数
1.8392867552
比率 (T20/T19)
1.8392873975
数列
| n | トリボナッチ |
|---|---|
| 0 | 0 |
| 1 | 0 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 4 |
| 6 | 7 |
| 7 | 13 |
| 8 | 24 |
| 9 | 44 |
| 10 | 81 |
| 11 | 149 |
| 12 | 274 |
| 13 | 504 |
| 14 | 927 |
| 15 | 1705 |
| 16 | 3136 |
| 17 | 5768 |
| 18 | 10609 |
| 19 | 19513 |
トリボナッチについて
Each term is the sum of the three preceding terms. The ratio of consecutive terms converges to the Tribonacci constant ~1.8392867552141612.
このツールについて
トリボナッチ数列は、有名なフィボナッチ数列の一般化です。フィボナッチが直前の2つの数を足すのに対し、トリボナッチは直前の3つの数を足して次の数を生成します。自然界や数学、アルゴリズム解析に現れるため、再帰的なパターンや数学的成長を研究するのに有価値なツールです。このカウントでは、手計算やコードを書くことなく、トリボナッチ数列を素早く探索できます。
カウントを使うには、生成する数列の長さを入力し、必要に応じて最初の3つの値をカスタマイズします(デフォルトは0、0、1)。生成ボタンをクリックすると、数秒で完全な数列が表示されます。結果をクリップボードにコピーして、スプレッドシート、文書、プログラミングプロジェクトで使用できます。これは特に再帰数列を学ぶ学生、アルゴリズムチャレンジを実装する開発者、または数学的パターンを探索することに興味がある人に役立ちます。
よくある質問
コード実装
from decimal import Decimal
def tribonacci(n: int, a: int = 0, b: int = 0, c: int = 1) -> list[int]:
"""Generate the first n terms of the Tribonacci sequence."""
if n <= 0:
return []
seq = [a, b, c]
while len(seq) < n:
seq.append(seq[-1] + seq[-2] + seq[-3])
return seq[:n]
# Standard Tribonacci sequence
seq = tribonacci(20)
print("Tribonacci sequence (first 20 terms):")
print(seq)
# Show ratios converging to Tribonacci constant (~1.8392867552141612)
print("\nRatios (approaching Tribonacci constant):")
for i in range(5, 20):
ratio = seq[i] / seq[i-1] if seq[i-1] != 0 else 0
print(f"T({i})/T({i-1}) = {seq[i]}/{seq[i-1]} ≈ {ratio:.10f}")
# Custom starting values
custom = tribonacci(15, a=1, b=1, c=2)
print("\nCustom (1,1,2):", custom)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.