public class LcmCgm {
private static int lcm;
private static int cgm;
private static int gcm;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = 0,b = 0,big = 0,small = 0;
try{
a=input.nextInt();
b=input.nextInt();
if(a<=b){big=b;small=a;}
if(a>b){big=a;small=b;}
}catch(Exception e){e.printStackTrace();}
int mog,nmg;
for(;;){
mog=(big/small);
nmg=big-(mog*small);
if(nmg==0){gcm=small; lcm =a*b/gcm;break;}else{big=small; small=nmg;}
}
System.out.println("두 수 " + a+", "+b+"의" );
System.out.println("최대공약수 gcm: " + gcm + " 최소공배수 lcm: " + lcm);
}
}
시나공 정보처리기사 실기 ㅇㅇ
물론, 자바는 안나옴.. 자바는 자바300제 ㅇㅇ
200제구나..