Computer Science, asked by 52331, 9 months ago

write a java program to generate the following seroes upto 10 terms
0,3,8,15,24,35..............

Answers

Answered by codiepienagoya
2

Program:

public class Main //defining class main.

{

public static void main(String[] args) //defining main method.  

{

 int i,x; //defining variable  

 System.out.print("The series is :\n");

       for(i=1;i<=10;i++) //loop for calculate series

       {

           x=i*i-1; //holds value

     System.out.print(x+","); //print values

       }

}

}

Output:

The series is :

0,3,8,15,24,35,48,63,80,99,

Explanation:

  • In the above java code, a class that is "Main" is defined that contains the main method. Insides the main method the two integer variable that is "i and x" and a for loop is declared.  
  • In the next line the for loop use variable i, that starts from 0 and ends with 10. and this variable (i) calculates series and uses variable x to holds its value and print the given series.

Learn more:

  • What is a series or pattern: https://brainly.com/question/13628676    
  • Sum of series: https://brainly.in/question/7356573  
Similar questions