View Code of Problem 59

#include<stdio.h>
void main(){
	int m,n,t;
	int i,j;
	scanf("%d%d",&m,&n);
	if(m<n){
		t=m;
		m=n;
		n=t;
	}
	for(i=m;;i--){
		if(m%i==0&&n%i==0)
			break;
	}
	for(j=1;;j++){
		if((m*j)%n==0)
			break;
	}
	printf("%d %d\n",m*j,i);
}

Double click to view unformatted code.


Back to problem 59