write a program to print the tribonacci series(in java)
Answers
Answered by
80
Hello dear …
Your program is answered below …
import java.util.*;
import java.io.*;
class Tribonacci
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number till u want Tribonacci series: ");
int n=sc.nextInt();
int a = 0,b = 0,c = 1;
int d = a+b+c;
System.out.println("\nTribonacci Series: ");
System.out.print(a+"\t"+b+"\t"+c);
for(int i=4;i<=n;i++)
{
System.out.print("\t"+d);
a=b;
b=c;
c=d;
d=a+b+c;
}
System.out.println();
}
}
Your program is answered below …
import java.util.*;
import java.io.*;
class Tribonacci
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number till u want Tribonacci series: ");
int n=sc.nextInt();
int a = 0,b = 0,c = 1;
int d = a+b+c;
System.out.println("\nTribonacci Series: ");
System.out.print(a+"\t"+b+"\t"+c);
for(int i=4;i<=n;i++)
{
System.out.print("\t"+d);
a=b;
b=c;
c=d;
d=a+b+c;
}
System.out.println();
}
}
TheEdward:
What is the difference
Answered by
11
Answer:
Here's your answer.
Explanation:
Please mark as Brainliest
Attachments:
Similar questions