4. Write a program to find the sum of series, taking the value of 'a' and 'n' from the user
a + 1
a + 3
at 5 at 7
+
+... up to n terms
Answers
Answered by
1
Answer:
import java.util.Scanner;
public class series
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a = in.nextInt();
int n = in.nextInt();
int sum = 0;
for(int i=1 ; i<=n ; i++)
{
sum += (a + ++i);
}
System.out.print(sum);
}
}
Similar questions