Home | History | Annotate | Download | only in util
      1 package com.googlecode.mp4parser.util;
      2 
      3 public class Math {
      4     public static long gcd(long a, long b) {
      5         while (b > 0) {
      6             long temp = b;
      7             b = a % b; // % is remainder
      8             a = temp;
      9         }
     10         return a;
     11     }
     12 
     13     public static int gcd(int a, int b) {
     14         while (b > 0) {
     15             int temp = b;
     16             b = a % b; // % is remainder
     17             a = temp;
     18         }
     19         return a;
     20     }
     21 
     22     public static long lcm(long a, long b) {
     23         return a * (b / gcd(a, b));
     24     }
     25 
     26     public static int lcm(int a, int b) {
     27         return a * (b / gcd(a, b));
     28     }
     29 
     30 }
     31