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
Logi sisse, et näha esituste ajalugu
Logi sisseLogi sisse, et kasutada AI mentorit
Logi sisseTests12
Visible tests
Peidetud test 7
Peidetud test 8
Peidetud test 9
Peidetud test 10
Peidetud test 11
Peidetud 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