int tribonacci(int n){
if (n == 0) return 0;
else if (n == 1 || n == 2) return 1;
int t0=0, t1=1,t2=1,i,num=0;
for (i=3; i<=n; i++)
{
num = t0 + t1 + t2;
t0 = t1;
t1 = t2;
t2 = num;
}
return num;
}