JAva毎日小アルゴリズム(6)


/*【  6】
  :       m n,             。
1.    :     。  */
package test;
public class test {
    //     
     public static int commonisor(int n, int m) {
         int max = (n>=m)?n:m;
         int min = (n>=m)?m:n;
         int r = max % min;
         while(r != 0)
         {
             max = min;
             min = r;
             r = max % min;
         }
         return min;
     }
        //     
     public static int commonmilt(int n, int m) {
         int commonisor = commonisor(n,m);
         int result = n / commonisor * m;
         return result;
     }
 public static void main(String[] args) {
     long a = System.currentTimeMillis();
     int n = 81;
     int m = 9;
     System.out.println("Commonisor of "+n+" and "+m+" is: "+commonisor(n,m));
     System.out.println("Commonmilt of "+n+" and "+m+" is: "+commonmilt(n,m));
     System.out.println(System.currentTimeMillis() - a);
 }
}