Hello, help needed again.
I have successfully written a method that accepts 2 integers and checks for a great common divider using a Euclidean algorithm.
Now I have to write a recursive method which accepts an array, and returns True if all numbers in the array are Coprime (dividable by '1' only and no greater number) with each other .
It is stated that no loops should be used.
From my understanding, the recursive "array checker" uses the 2 integers checker. How can I pass the "gcd" method the values each time, without a loop?
Does it involves using a linked list somehow?
Any help please.
I have successfully written a method that accepts 2 integers and checks for a great common divider using a Euclidean algorithm.
Now I have to write a recursive method which accepts an array, and returns True if all numbers in the array are Coprime (dividable by '1' only and no greater number) with each other .
It is stated that no loops should be used.
From my understanding, the recursive "array checker" uses the 2 integers checker. How can I pass the "gcd" method the values each time, without a loop?
Code:
public static boolean checkGCD (int[] values)
{
boolean result = true;
int gcd;
gcd = GcdTester.gcd // that "gcd" method accepts 2 ints, but how to pass them to it, incrementing each time
if (gcd != 1)
result = false;
else
GcdTester.checkGCD (values);
return (result);
}
Does it involves using a linked list somehow?
Any help please.