Skip to content
Onsite

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

Run checks the 3 visible tests, Submit all 10.