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

Aici va apărea rezultatul execuției codului

Tests12
Visible tests
Test ascuns 7
Test ascuns 8
Test ascuns 9
Test ascuns 10
Test ascuns 11
Test ascuns 12

They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.

Focus radio
Paused · SomaFM · Fluid