Computer Science, asked by sangamyadav8107, 5 months ago

Write a
program to
display
First for ten term
2 ,5,10,17​

Answers

Answered by udayagrawal49
22

Answer: The required Java program is :-

public class SpecialSeries {

public static void main(String[] args) {

    int k=1;

    for (int j=0 ; j<10 ; j++) {

        k = k+(2*j+1);

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

    }

  }

}

This code is stored in a file named SpecialSeries.java. Here, we have initialized a variable k with value 1 and a variable j with value 0. for-loop is used to print the value k and hence, to print the required pattern.


udayagrawal49: thanks :)
Similar questions