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
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saTests12
Visible tests
Skrytý test 7
Skrytý test 8
Skrytý test 9
Skrytý test 10
Skrytý test 11
Skrytý test 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