Problem
The Tribonacci sequence starts T0 = 0, T1 = 1, T2 = 1, and every later term is the sum of the three terms before it: T(n) = T(n - 1) + T(n - 2) + T(n - 3). Return T(n).
Example 1
- Input
- n = 4
- Output
- 4
- Why
- 0, 1, 1, 2, 4
Example 2
- Input
- n = 25
- Output
- 1389537
Example 3
- Input
- n = 0
- Output
- 0
Constraints
0 <= n <= 37The answer fits in a 32-bit integer.