View Code of Problem 57

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	int x=0,y=0,t=0;
	scanf("%d%d",&a,&b);
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	x=a%b;
	y=a*b;
	while(x!=0){
		a=b;
		b=x;
		x=a%b;
	}
	printf("%d %d",y/b,b);
}

Double click to view unformatted code.


Back to problem 57