Series 7
1+3+6+10+15+21+..........upto n terms.
/* The series can be computer by taking the sum of natural numbers.*/
import java.io.*;
class Series9{
public static void main(String args[])throws IOException{
//declare all the variables at the beginning
int i,a,n;
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter the number of terms : ");
n=Integer.parseInt(br.readLine());
a=0;
for(i=1;i<=n;i++){
a=a+i;
System.out.print(a+" ");
}//end of loop
}//end of main
}//end of class
Have something to say? Log in to comment on this post.
0 comments