View Code of Problem 59

#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int gcd(int a,int b)
{
	return a%b==0 ? b:gcd(b,a%b);
}

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b)
	swap(a,b);
	int maxnum=gcd(a,b);
	int minnum=a*b/maxnum;
	cout<<minnum<<" "<<maxnum;
	return 0;
}

Double click to view unformatted code.


Back to problem 59