Skip to content

Instantly share code, notes, and snippets.

@Francis-McKee
Created February 6, 2024 20:12
Show Gist options
  • Save Francis-McKee/77e29899c137ec08352885664a937a33 to your computer and use it in GitHub Desktop.
Save Francis-McKee/77e29899c137ec08352885664a937a33 to your computer and use it in GitHub Desktop.
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