N-th Tribonacci Number
EasyP3Coding
The Tribonacci numbers are defined by T0 = 0, T1 = 1, T2 = 1, and Tn = T(n-1) + T(n-2) + T(n-3) for n >= 3. Return Tn.
Example 1
- Input
- n = 4
- Output
- 4
- Why
- T3 = 0 + 1 + 1 = 2, T4 = 1 + 1 + 2 = 4.
Example 2
- Input
- n = 25
- Output
- 1389537
Example 3
- Input
- n = 0
- Output
- 0
Constraints
- 0 <= n <= 60
- The answer fits in a 53-bit integer.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.