Computer Applications
Write a program in Java to find the sum of the given series:
S = (a*2) + (a*3) + …… + (a*20)
Answer
import java.util.Scanner;
public class KboatSeries
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a: ");
int a = in.nextInt();
long sum = 0;
for (int i = 2; i <= 20; i++)
sum += a * i;
System.out.println("Sum = " + sum);
}
}
Variable Description Table
Program Explanation
Output
Related Questions
Write a program in Java to find the sum of the given series:
S = a2 + a2 / 2 + a2 / 3 + …… + a2 / 10
Write a program in Java to find the sum of the given series:
S = a + a2 / 2 + a3 / 3 + …… + a10 / 10
Write the program to find the sum of the following series:
S = a + a2 + a3 + ……. + an
Write a program in Java to find the sum of the given series:
S = 1 + 22 / a + 33 / a2 + …… to n terms