Last active
September 22, 2016 14:49
-
-
Save devetude/b53eebe29ebbb96400487f4f5c43ab00 to your computer and use it in GitHub Desktop.
유클리드 최대공약수 알고리즘 2 (Euclid GCM 2)
This file contains 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
import java.util.Scanner; | |
/** | |
* 유클리드 최대공약수 알고리즘 2 (Euclid GCD 2) | |
* | |
* @author devetue | |
*/ | |
public class Main { | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int a = sc.nextInt(); | |
int b = sc.nextInt(); | |
sc.close(); | |
while (true) { | |
if (b == 0) { | |
System.out.println(a); | |
break; | |
} | |
int tmp = b; | |
b = a % b; | |
a = tmp; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment