JAVA PROGRAM
Write two separate program to find the sum of the following series:
i) =
1
+1
+
2
+2
+
3
+3
+ ⋯ … … … … … … … . . +
10
+10
ii) s = 1+ 4 +9 +16 + 25 +………. n terms
PLZZ NEED IT FAST ITS URGENT AND PLZZ GIVE THE CORRECT ANSWER TIME TILL(10.30) U ARE THE ONLY PERSON WHO CAN SAVE ME PLEASE
Answers
Answered by
0
import java.util.Scanner;
public class KboatSeries
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter n: ");
int n = in.nextInt();
double sum = 0.0;
for (int i = 2; i <= n; i++) {
double num = 0.0, den = 1.0;
for (int j = 1; j <= i; j++) {
num += j;
den *= j;
}
sum = sum + (num / den);
}
System.out.println("Sum=" + sum);
}
Similar questions