Computer Science, asked by ruhi668, 10 months ago

write a java program to find the sum of the following series s=1+(1+2)+(1+2+3)+……+(1+2+3+…..+n)

Answers

Answered by sswaraj04
28

Answer:

import java.util.Scanner;

public class HelloWorld{

    public static void main(String []args){

        Scanner sc=new Scanner(System.in);

       

       System.out.println("Enter number of terms you want the sum :");

       int n=sc.nextInt();

       int sum=0,fsum=0;

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

       {

           sum+=i;

           fsum+=sum;

       }

       System.out.println("Sum is "+fsum);

    }

}

Explanation:

Hope it helps :-)

Answered by Anonymous
3

Explanation:

CORRECT ANSWER is in the attached file

hope it helps..

Attachments:
Similar questions