Computer Science, asked by 120asthayadav55, 8 months ago

write a program in java to find the sum of the given series,a)s=a*2+a*3+...a*20

Answers

Answered by StephenDeva
0

Answer:

import java.io.*;

class GFG

{

public static void main (String[] args)

{

double n = 20, a = 2;

System.out.println(sumOfSeries(a, n));

}

static double sumOfSeries(double a,double n)

{

double res = 0, prev = 1;

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

{

prev = a * i ;

res = res + prev;

}

return(res);

}

}

Answered by tanu8979
2

Answer:

Class sum

{

public static void main(int a)

{

int s=0;

for(int i=2;i<=20;i++)

{

s=a*i;

System.out.print("sum="+s);

}

}

}

Explanation:

I have made is Simple If you want it with Buffered Redader

then write the Syntax of Buffered Reader and assign 'a'

as

a=br.readLine()

Similar questions