Skip to content

Commit

Permalink
N-th Tribonacci Number
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sukhoverkhov committed Aug 17, 2024
1 parent e96cb2b commit 2f263fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/leetcode/N-th Tribonacci Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def tribonacci(self, n: int) -> int:

fibo = [0, 1, 1]
for i in range(3, n+1):
fibo.append(
fibo[i-3] + fibo[i-2] + fibo[i - 1]
)

return fibo[n]


if __name__ == "__main__":
obj = Solution()

assert obj.tribonacci(4) == 4

0 comments on commit 2f263fd

Please sign in to comment.