write a program in java to to find the sum of the given series 1/a+1/a2+1/a3....... +/an
Answers
Answered by
8
Explanation:
# a Java program
import java.util.*;
class Sum_series
{
public static void main (String args[])
{
Scanner sc=new Scanner (System.in());
double sum=0;
System.out.println("enter the value of n");
int n=sc.nextInt();
System.out.println("enter "+n+" numbers");
for(int i=1;i<=n;i ++)
{
a=sc.nextInt();
sum=sum+1.0/a;
}
System.out.println("sum of series="+sum);
}
}
Similar questions
Biology,
5 months ago
Math,
5 months ago
English,
5 months ago
Math,
11 months ago
Physics,
11 months ago
Accountancy,
1 year ago
Accountancy,
1 year ago