structy-logo
Pythonpython3logo
Course Contents
Layout 1
Prompt
Editor
Terminal
sign in
problem
approach
walkthrough
solution
add to favoritessettings

tribonacci

Write a function tribonacci that takes in a number argument, n, and returns the n-th number of the Tribonacci sequence.

The 0-th and 1-st numbers of the sequence are both 0.

The 2-nd number of the sequence is 1.

To generate further numbers of the sequence, calculate the sum of previous three numbers.

Solve this recursively.

test_00
tribonacci(0) # -> 0
test_01
tribonacci(1) # -> 0
test_02
tribonacci(2) # -> 1
test_03
tribonacci(5) # -> 4
test_04
tribonacci(7) # -> 13
test_05
tribonacci(14) # -> 927
test_06
tribonacci(20) # -> 35890
test_07
tribonacci(37) # -> 1132436852
terminal
settings
[guest]$ 
editor — tribonacci.py
reset codesettings
def tribonacci(n):
pass # todo

saved