Menu
Question Index
...

Write a program to find the sum of the reciprocals of given numbers

Input (int[]) Output (double)
{3, 2, 1} (1/3)+(1/2)+(1/1)
= 1.8333333333333333
{5, 2, 7, 1} 1.8428571428571427
{1, 8, 5, 2, 10} 1.925
{2, 4, 3, 5, 7, 8} 1.5511904761904762
{4, 6, 7, 9, 2, 1, 11} 2.2615440115440117



class SumOfTheReciprocals
{
    public static void main(String s[])
    {
        int inputArray[] = {4, 2, 3};
        System.out.println("The sum of reciprocals of the given numbers is " + findSumOfReciprocals(inputArray));

    }


    public static double findSumOfReciprocals(int[] input) {
    }

}

Doubts

Problems

Topic: For-each Loop In Core Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App