Write a program in Java to print the sum of the series
1 – 2 + 32 – 4 + 5 - 62 + 7 – 8 + 92 – 10 …n terms
Answers
Answered by
19
Explanation:
// JAVA program to find summation of series
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
class GFG
{
// function to calulate sum of series
static int summingSeries(long n)
{
// use of loop to calculate
// sum of each term
int S = 0;
for (i = 1; i <= n; i++)
S += i * i - (i - 1) * (i - 1);
return S;
}
// Driver code
public static void main(String[] args)
{
int n = 100;
System.out.println("The sum of n term is: " +
summingSeries(n));
}
}
Answered by
0
Answer:
Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
plz mark as brainliest
have a great day
Similar questions