viligen

tribonacci

Oct 11th, 2021 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. def tribonacci(num):
  2.     tribonacci_list = [1]
  3.  
  4.     for i in range(num - 1):
  5.         new_element = sum(tribonacci_list[-1:-4:-1])
  6.         tribonacci_list.append(new_element)
  7.     return tribonacci_list
  8.  
  9.  
  10. number = int(input())
  11. print(*tribonacci(number))
  12.  
Add Comment
Please, Sign In to add comment