The Tribonacci sequence extends the idea of Fibonacci by summing the previous three terms instead of two.
It begins with:
T₀ = 0
T₁ = 1
T₂ = 1
For all n ≥ 0:
Tₙ₊₃ = Tₙ + Tₙ₊₁ + Tₙ₊₂
Your task is to compute and return Tₙ for a given integer n.
Input: n = 0
Output: 0
Input: n = 3
Output: 2
Explanation:
T₃ = T₀ + T₁ + T₂ = 0 + 1 + 1 = 2
Accepted:
Submission: