Problem
The Tribonacci sequence is a list of numbers T(0), T(1), T(2), and so on. The sequence starts with T(0) = 0, T(1) = 1 and T(2) = 1.
Each next number is the sum of the three numbers before it: T(i + 3) = T(i) + T(i + 1) + T(i + 2).
You get an integer n. Return the value of T(n).
Example 1
- Input:
- n = 5
- Output:
- 7
- Explanation:
T(3) = 0 + 1 + 1 = 2.T(4) = 1 + 1 + 2 = 4.T(5) = 1 + 2 + 4 = 7.
Example 2
- Input:
- n = 0
- Output:
- 0
Example 3
- Input:
- n = 10
- Output:
- 149
Constraints
- 0 <= n <= 37
- The answer fits in a 32-bit integer.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1137. N-th Tribonacci Number
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source