public class Test001 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x, y, r;
System.out.print("두개의 정수를 입력하시오(큰수, 작은수):");
x = sc.nextInt();
y = sc.nextInt();
while (y > 0) {
r = x % y;
x = y;
y = r;
}
System.out.printf("최대 공약수는 %d", x);
}
}
댓글 없음:
댓글 쓰기