Advertisement
Spocoman

04. Tribonacci Sequence

Jan 31st, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. def tribonachi ():
  2.     num = [0, 0, 1]
  3.     for i in range(2, int(input()) + 1):
  4.         num.append(num[i] + num[i - 1] + num[i - 2])
  5.     while 0 in num: num.remove(0)
  6.     return num
  7.  
  8. print(*tribonachi())
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement