Find The HCF Of All Numbers In The Array - Java Quiz Question



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.
}
}