Computer Science, asked by mousumiroy218, 9 months ago

wap in java to print the following series: s = (a*2) + (a*3) +..... + (a*20)

Answers

Answered by Anonymous
8

import java.util.*;

public class Series

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

int s=0,a,i;

System.out.println("Enter the value of a");

a= in.nextInt();

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

{

a=a*i;

s=s+a;

System.out.println("The series is="+s);

}

}

}

//We should use Scanner class to take input.

//As the program have to run several times during this process so we should use for loop.

//Except 'buffered reader' using 'scanner class', because, we are using the utilization process and in utilization process there is no such key word as, 'buffered reader'.

Similar questions