Created
November 25, 2012 17:11
-
-
Save lounestor/4144357 to your computer and use it in GitHub Desktop.
determining Greatest Common Divisor and Lowest Common Multiple
This file contains hidden or 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 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