Three-Step Sequence

Tribonacci is like Fibonacci, but each new number is the sum of the previous three. The sequence starts with T(0) = 0, T(1) = 1, and T(2) = 1. Given n, return T(n) using the rule T(n+3) = T(n) + T(n+1) + T(n+2).

Примеры

Ввод
4
Вывод
4
Ввод
25
Вывод
1389537
Ввод
0
Вывод
0

Нужно реализовать

def tribonacci(n: int) -> int:

Теги

dpmath
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
4
Expected4
2
Input
25
Expected1389537
3
Input
0
Expected0
4
Input
1
Expected1
5
Input
2
Expected1
6
Input
-100
Expected1
Focus radio
Paused · SomaFM · Fluid