View Code of Problem 59

#include<stdio.h>
#include<math.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int n,m,k;
	if(a>b)
	n=a,m=b;
	else
	n=b,m=a;
	while(1)
	{
		k=n%m;
		if(k==0)
		break;
		n=m,m=k;
	}
	printf("%d %d",a*b/m,m);
}   

Double click to view unformatted code.


Back to problem 59