Skip to content

Instantly share code, notes, and snippets.

@dvt32
Last active September 3, 2022 08:35
Show Gist options
  • Save dvt32/0f833464912596190825486de466ed6e to your computer and use it in GitHub Desktop.
Save dvt32/0f833464912596190825486de466ed6e to your computer and use it in GitHub Desktop.
ALGORITHMO #9 - Euclidean Algorithm Implementation
public class Solution {
static int getGreatestCommonDivisor(int a, int b) {
while (b != 0) {
int temp = a;
a = b;
b = temp % b;
}
int greatestCommonDivisor = a;
return greatestCommonDivisor;
}
public static void main(String[] args) {
System.out.println(
getGreatestCommonDivisor(2505, 9775)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment