View Code of Problem 59

#include<iostream>

using namespace std;

int gcd(int a,int b){
	int temp;
	if(a>b){
		temp=a%b;
		if(temp==0){
			return b;
		} else {
			return gcd(b,temp);
		}
	} else {
		temp=b%a;
		if(temp==0){
			return a;
		} else {
			return gcd(a,temp);
		}
	}
}

int main(){
	int a;
	int b;
	cin>>a>>b;
	int res1=gcd(a,b);
	int res2=a*b/res1;
	cout<<res2<<" "<<res1;
	return 0;
} 

Double click to view unformatted code.


Back to problem 59