Follow on Facebook

Like and Share on Facebook

Monday, February 9, 2015

Write a Program to Sum of the Series of "1, 4, 9, 16...400" in Java


Write a Program to Sum of the Series of "1, 4, 9, 16..." in Java


import java.io.*;
class AddSeries
{
   public static void main(String args[])
   {
      int i,j=0,sum=0;
 
          for(i=1;i<=10;i++)
             {
                       j = i *i;;
                        sum=sum+j;
      System.out.println("\nSeris of entered integers = "+j);
              }
      System.out.println("\nSum of Series = "+sum);
   }
}

Output:
Series of entered integer=
1
4
9
16
25
36
49
64
72
81
100

Sum of Series is=457

1 comment: