Created
February 6, 2024 20:12
-
-
Save Francis-McKee/77e29899c137ec08352885664a937a33 to your computer and use it in GitHub Desktop.
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 Main { | |
public static void main(String[] args) { | |
int a = 108; | |
int b = 48; | |
System.out.println("GCD of a and b is " + calcGcd(a, b)); | |
} | |
// method to calculate the GCD | |
public static long calcGcd(int a, int b) { | |
if (b != 0) { | |
return calcGcd(b, a % b); | |
} else { | |
return a; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment