GeorgiLukanov87

tribonaci

May 31st, 2022 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def tribanacci(sequence: list, number):
  2.     if number > 3:
  3.         for iteration in range(number - 3 + 1):
  4.             num = sum(sequence[-3:])
  5.             sequence.append(num)
  6.         return sequence
  7.     return sequence[:number]
  8.  
  9. n = int(input())
  10. tribonacci_list = [1, 1]
  11.  
  12. result = tribanacci(tribonacci_list, n)
  13.  
  14. print(' '.join(list(map(str, result))))
Add Comment
Please, Sign In to add comment