View Code of Problem 59

#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int max,min;
	if(a>b){
		int temp=a;
		a=b;
		b=temp;
	}
	for(int i=a;i>=2;i--){
		if(a%i==0&&b%i==0){
			max=i;
			break;
		}
	}
	min=a*b/max;
	printf("%d %d",min,max);
	return 0;
}

Double click to view unformatted code.


Back to problem 59