Program to generates and find thw sum of the series, 1+4+9+16+…………..

class test
{ public static void main(String[] asd)throws IOException
BufferedReader obj= new BufferedReader(new InputStreamReader(;
int n,sum=0;
String num;

System.out.println("Enter a number::");
for(int i=1;i<=n;i++)
sum=sum+ i*i;
System.out.print(i*i+" ");
System.out.println("Sum of the series is="+sum+".");

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s