Program to find the sum of the series, 3+5+9+15+……..

class test
public static void main(String[] asd)throws IOException
BufferedReader obj= new BufferedReader(new InputStreamReader(;
String num;
int n,sum=3, result=0;
System.out.print("Enter the value till you want the sum of the series.");
System.out.println("SERIES IS::");
System.out.print("3 ");
for(int i=0;i<n;i++)
sum=sum+ (2*(i+1));
System.out.print(sum+" ");
System.out.println("Sum of the series:: "+(result+3)+".");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s