Computer Science, asked by tulikasingh19sp77sut, 1 year ago

generate the following series upto terms in java or bluej 1,4,7,10....

Answers

Answered by pranvi2704
0

import java.util. *;

class series

{

public static void main ()

{

Scanner sc = new Scanner System.in ( )

System.out.println("Enter the number of terms");

int n=sc.nextInt ( );

int a,sum=0;

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

{

sum=sum+a;

a+=3

}

System.out.println(sum );

}

}

Similar questions