#C12422. Tribonacci Sequence Calculator
Tribonacci Sequence Calculator
Tribonacci Sequence Calculator
In this problem, you are required to compute the Tribonacci number at a given index n. The Tribonacci sequence is defined as follows:
\(T(0)=0, \quad T(1)=1, \quad T(2)=1,\)
and for \(n > 2\):
\(T(n)=T(n-1)+T(n-2)+T(n-3)\)
Your task is to calculate \(T(n)\) efficiently. Make sure your solution reads the input from stdin and writes the output to stdout.
inputFormat
The input consists of a single integer n
which is the index in the Tribonacci sequence.
You should read from stdin.
outputFormat
Output the n
th Tribonacci number to stdout.
0
0