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
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänTests12
Visible tests
Piilotettu testi 7
Piilotettu testi 8
Piilotettu testi 9
Piilotettu testi 10
Piilotettu testi 11
Piilotettu testi 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