Computer Science, asked by Ronald11, 1 year ago

WAP in java to print the series
1>1^2 + 2^2 + 3^2 +......................n

Answers

Answered by anuj
1
Heya!!
the program is as follows:-


import java.io.*;
class series
{
  public static void main()throws IOException
    {
         DataInputStream ak = new DataInputStream(System.in);

           System.out.println("Enter a number till u want sum");

             int n=Integer.parseInt(ak.readLine());

                 int sum =0;

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

             sum = sum+ (i*i);

            }
      System.out.println("SUM IS "+sum);
   }
}                   
       

HOPE IT HELPS!!!!!!!!!!!!!!!!!!

Similar questions