View Code of Problem 59

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;

int gcd(int a,int b) {
	if(a<b) {
		int temp=a;
		a=b;
		b=temp;
	}
	while(b!=0) {
		int temp=a%b;
		a=b;
		b=temp;
	}
	return a;
}


int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d %d",a*b/gcd(a,b),gcd(a,b));

}

Double click to view unformatted code.


Back to problem 59