View Code of Problem 59

#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {
	int c;
	while(b) {
		c=a%b;
		a=b;
		b=c;
	}
	return a;
} 
 
int main()
{
	int n,m;
	while(cin>>m>>n) {
		int a=gcd(m,n);
		int b=m*n/a;
		cout<<b<<" "<<a<<endl;
	}
	
	return 0;
	
}

Double click to view unformatted code.


Back to problem 59