mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 02:53:15 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -40,8 +40,7 @@ public class GCD {
|
||||
*/
|
||||
public static int gcd(int[] number) {
|
||||
int result = number[0];
|
||||
for (int i = 1; i < number.length; i++) // call gcd function (input two value)
|
||||
{
|
||||
for (int i = 1; i < number.length; i++) { // call gcd function (input two value)
|
||||
result = gcd(result, number[i]);
|
||||
}
|
||||
|
||||
@ -49,10 +48,14 @@ public class GCD {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] myIntArray = {4, 16, 32};
|
||||
int[] myIntArray = { 4, 16, 32 };
|
||||
|
||||
// call gcd function (input array)
|
||||
System.out.println(gcd(myIntArray)); // => 4
|
||||
System.out.printf("gcd(40,24)=%d gcd(24,40)=%d%n", gcd(40, 24), gcd(24, 40)); // => 8
|
||||
System.out.printf(
|
||||
"gcd(40,24)=%d gcd(24,40)=%d%n",
|
||||
gcd(40, 24),
|
||||
gcd(24, 40)
|
||||
); // => 8
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user