A tribonacci series is one in which the sum next term is the sum of previous three terms eg. 0 1 2 3 6 11 20
public class Tribonacci
{
public static void main(String args[])
{
int a=0, b=1, c= 2, d=0;
System.out.print( a +" "+ b + " "+ c);
for(int i=1;i<=10;i++)
{
d=a+b+c;
System.out.print(" "+ d);
a=b;
b=c;
c=d;
}
}
}
Output:
0 1 2 3 6 11 20 37 68 125 230 423 778
public class Tribonacci
{
public static void main(String args[])
{
int a=0, b=1, c= 2, d=0;
System.out.print( a +" "+ b + " "+ c);
for(int i=1;i<=10;i++)
{
d=a+b+c;
System.out.print(" "+ d);
a=b;
b=c;
c=d;
}
}
}
Output:
0 1 2 3 6 11 20 37 68 125 230 423 778