Last active
September 3, 2022 08:35
-
-
Save dvt32/0f833464912596190825486de466ed6e to your computer and use it in GitHub Desktop.
ALGORITHMO #9 - Euclidean Algorithm Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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