English

Write the program in Java to display the first ten terms of the following series: 0, 1, 2, 3, 6, ................ - Computer Applications

Advertisements
Advertisements

Question

Write the program in Java to display the first ten terms of the following series: 

0, 1, 2, 3, 6, ................

Answer in Brief

Solution

public class Q1a
{ public static void main(String args[])
{ int a = 0, b = 1, c = 2, d = 0;
System.out.println("TRIBONACCI SERIES"); // optional
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;
}
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.09: Iterative Constructs in Java - EXERCISES [Page 124]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.09 Iterative Constructs in Java
EXERCISES | Q VI. 1. (a) | Page 124
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×