View Code of Problem 59

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int temp;
	int ch=n*m;
	if(n<m){
		temp=n;
		n=m;
		m=temp;
	}
	int chu=n%m;
	if(chu==0){
		cout<<ch/m<<" "<<m;
	}
	else{
		while(chu!=0){
			n=m;
			m=chu;
			chu=n%m;
		}
		cout<<ch/m<<" "<<m;
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 59