Computer Science, asked by chayanikaniyogi, 11 months ago

write a program in java to to find the sum of the given series 1/a+1/a2+1/a3....... +/an​

Answers

Answered by Anonymous
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