write a program to print the tribonacci series. With answer
Answers
Answer:
import java.util.*;
public class tribonacci
{
public static void main()
{
Scanner sc = new Scanner (System.in);
int a=0,b=1,c,d;
c=a+b;
d=a+b+c;
System.out.println(+a);
System.out.println(+b);
System.out.println(+c);
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
a=b;
b=c;
c=d;
d=a+b+c;
System.out.println(+d);
}
}
just fyi, this will print the tribonacci many times
hope my answer helps..