1137. N-th Tribonacci Number

Easy

3.4K

157

The Tribonacci sequence T_{n} is defined as follows:

T_{0} = 0, T_{1} = 1, T_{2} = 1, and T_{n+3} = T_{n} + T_{n+1} + T_{n+2} for n >= 0.

Given `n`

, return the value of T_{n}.

**Example 1:**

Input:n = 4Output:4Explanation:T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4

**Example 2:**

Input:n = 25Output:1389537

**Constraints:**

`0 <= n <= 37`

- The answer is guaranteed to fit within a 32-bit integer, ie.
`answer <= 2^31 - 1`

.

Accepted

471.9K

Submissions

740.5K

Acceptance Rate

63.7%

Seen this question in a real interview before?

1/4

Yes

No

Discussion (0)

Related Topics

Copyright ©️ 2023 LeetCode All rights reserved