Skip to content

Instantly share code, notes, and snippets.

@lounestor
Created November 25, 2012 17:11
Show Gist options
  • Select an option

  • Save lounestor/4144357 to your computer and use it in GitHub Desktop.

Select an option

Save lounestor/4144357 to your computer and use it in GitHub Desktop.
determining Greatest Common Divisor and Lowest Common Multiple
public class CommonDenominator {
public static void main(String[] args) {
System.out.println(GCD(64,40)+"...................");
System.out.println(LCM(24, 60));
}
public static int GCD(int a, int b) {
if (b==0) return a;
return GCD(b,a%b);
}
public static int LCM(int a, int b) {
return a*b/GCD(a,b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment