Skip to content

Latest commit

 

History

History

Tribonacci Number

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Tribonacci Number using Memoization

The Tribonacci sequence Tn is defined as follows:

T(0) = 0, T(1) = 1, T(2) = 1
T(n + 3) = T(n) + T(n + 1) + T(n + 2) for n >= 0.

Given n, calculate T(n).

Example 1:

Input: n = 2
Output: 1

Example 2:

Input: n = 3
Output: 2

Example 3:

Input: n = 4
Output: 4