Computer Science, asked by allmyccnt, 10 months ago

Write programs in Java to find the sum of the following series: S = a + a^2 + a^3 + ....... + a^n

Attachments:

Answers

Answered by yashahuja312
4

Answer:

import java.util.Scanner;

public class HelloWorld{

   public static void main(String []args){

       Scanner sc=new Scanner(System.in);

      

      System.out.printlng("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);

   }

}

HOPE IT HELPS YOU

PLEASE MARK ME THE BRAINLIEST

Similar questions