Computer Science, asked by abhinavmikraistar, 3 months ago

Write a Java program to print the following series:

0,1,2,3,6

Print 11 number in the series​

Answers

Answered by Anonymous
4

\huge\pink{\fbox{\fbox{\fbox{Answer:}}}}

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 < = 11 ; i ++ )

{

d = a + b + c ;

System.out.print ( " " + d ) ;

a = b ;

b = c ;

c = d ;

}

}

}

Answered by Innocentgirl58
1

Answer:

public class Fibonacci {

public static void main(String[] args) {

int n = 10, t1 = 0, t2 = 1;

System.out.print("First " + n + " terms: ");

for (int i = 1; i <= n; ++i)

{

System.out.print(t1 + " + ");

int sum = t1 + t2;

t1 = t2;

t2 = sum;

}

}

}

Similar questions