diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/1137. N-th Tribonacci Number.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/1137. N-th Tribonacci Number.py" new file mode 100644 index 00000000..97749977 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/1137. N-th Tribonacci Number.py" @@ -0,0 +1,17 @@ +class Solution: + def tribonacci(self, n: int) -> int: + if n == 0: + return 0 + if n == 1 or n == 2: + return 1 + a = 0 + b = 1 + c = 1 + + for i in range(n-2): + temp = a + b + c + a = b + b = c + c = temp + + return c