Answer:
import java.util.Scanner;
public class series {
public static void main(String args[])
{
double a,n;
double s=0;
Scanner obj=new Scanner(System.in);
System.out.println("Enter value of a:-");
a=obj.nextDouble();
System.out.println("Enter the number of terms:-");
n=obj.nextDouble();
for(int i = 1; i <= n ; i++)
s += Math.pow((double)(a /(i + 1)), 2.0);
}
System.out.println("Sum of the series:- " + s);
Copyright © 2024 EHUB.TIPS team's - All rights reserved.
Answers & Comments
Verified answer
Answer:
import java.util.Scanner;
public class series {
public static void main(String args[])
{
double a,n;
double s=0;
Scanner obj=new Scanner(System.in);
System.out.println("Enter value of a:-");
a=obj.nextDouble();
System.out.println("Enter the number of terms:-");
n=obj.nextDouble();
for(int i = 1; i <= n ; i++)
{
s += Math.pow((double)(a /(i + 1)), 2.0);
}
System.out.println("Sum of the series:- " + s);
}
}