나의 플랫폼/안드로이드

[ Android ] 최대 공약수 구하기

GsBOB 2011. 7. 22. 10:12

 public static int gcd(int a, int b) {
     while (b != 0) {
      int temp = a % b;
      a = b;
      b = temp;
     }
     return Math.abs(a);
 }