Menu
Question Index
...


Write a program to get the Highest Common Factor (HCF) of an array of numbers.

Input (Integer Array) Output(Integer)
{39, 65, 91, 117} 13
{364, 637, 819} 91
{14, 34, 90, 82, 58} 2
{5, 10} 5
{84} 84

class HCFOfArrayOfNumbers

{    public static void main(String s[])
    {
        int inputArray[] = {15, 30, 45};
        System.out.println("The Highest Common Factor is : " + getHcfOfAllElements(inputArray));

    }


public static int getHcfOfAllElements(int array[]) {
//Write code here to get the HCF of all the numbers in the array and return it. If required you can use getFactors method.
}

public static int[] getFactors(int number) {
//Write a code here to get the factors of a given number and return it.
}
}


Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App