Skip to content

Commit 3bd769d

Browse files
authored
Increase recursive GCD
1 parent 962720f commit 3bd769d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Others/GCD.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ public static int gcd(int a, int b) {
1313
return b;
1414
}
1515
}
16+
17+
//Increase the number of calculations.
18+
//Use functoin from above as recursive.
19+
public static int gcd(int[] number) {
20+
int result = number[0];
21+
for(int i = 1; i < number.length; i++)
22+
result = gcd(result, number[i]);
23+
return result;
24+
}

0 commit comments

Comments
 (0)