Increase recursive GCD

This commit is contained in:
teerapat1739 2017-10-28 01:19:55 +07:00 committed by GitHub
parent 962720fc6b
commit 3bd769d2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,3 +13,12 @@ public static int gcd(int a, int b) {
return b; return b;
} }
} }
//Increase the number of calculations.
//Use functoin from above as recursive.
public static int gcd(int[] number) {
int result = number[0];
for(int i = 1; i < number.length; i++)
result = gcd(result, number[i]);
return result;
}