Tribonacci Calculator
Generate the Tribonacci sequence and generalized variants with custom starting values.
Sequence
| n | Tribonacci |
|---|---|
| 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 |
About Tribonacci
Each term is the sum of the three preceding terms. The ratio of consecutive terms converges to the Tribonacci constant β 1.8392867552141612.
About this tool
The Tribonacci sequence is a generalization of the famous Fibonacci sequence, where each number is the sum of the three preceding numbers instead of two. Like Fibonacci, it appears in nature, mathematics, and algorithm analysis, making it a valuable tool for studying recursive patterns and mathematical growth. This calculator lets you explore Tribonacci numbers instantly, without needing to compute them by hand or write code.
To use the calculator, enter your desired sequence length and optionally customize the first three starting values (which default to 0, 0, and 1). Click Generate, and the tool will display the complete sequence in seconds. You can also copy the results to your clipboard for use in spreadsheets, documents, or programming projects. This is especially helpful for students learning about recursive sequences, developers implementing algorithm challenges, or anyone interested in exploring mathematical patterns.
Frequently Asked Questions
Code Implementation
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.