Write a program for tribonacci series. With answer
Answers
Answer:
Just fyi, this will print the tribonacci many times...
Explanation:
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);
}
}
hope my answer helps