Question: Write a method named arrayAllMultiples that, given an array of int values greater than 0, returns whether the values are all integer multiples of

Write a method named arrayAllMultiples that, given an array of int values greater than 0, returns whether the values are all integer multiples of one of the values in the array, which we'll call the base. For example, given the array {4, 2, 8} you would return true, since 4 and 8 are integer multiples of the base 2. Given the array {2, 2, 5} you would return false, since there is no value that all others are integer multiples of. (If the array contains 1, you should always return true, but there's no need to handle this case specifically.) You should approach this problem in two steps. First, identify the base the value in the array that you are going to check whether others are multiples of. This may sound complicated, but it's straightforward. You do not need to and should not check whether every value is base! Your solution should not contain a nested loop. Next, check all the values in the array and look for a counterexample-a value that is not a multiple of the base. The passed array may be null or empty. In those cases you should return false. Valid arrays will contain only integers strictly greater than 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
