Back to course home
0% completed
N-th Tribonacci Number (easy)
Problem Statement
The Tribonacci sequence T<sub>n</sub> is defined as follows:
T<sub>0</sub> = 0, T<sub>1</sub> = 1, T<sub>2</sub> = 1, and T<sub>n + 3</sub> = T<sub>n</sub> + T<sub>n+1</sub> + T<sub>n+2</sub> for n >= 0.
Given an integer n
, return the n<sup>th</sup> Tribonacci term T<sub>n</sub>.
Examples
Example 1
- Input: n = 5
- Expected Output: 7
- Justification: The sequence up to the 5th term is [0, 1, 1, 2, 4, 7]. The 5th term is 7.
Example 2
- Input: n = 8
- Expected Output: 44
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible