Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IAFahim/7713fd07d0b77c4cee044ed9712e794d to your computer and use it in GitHub Desktop.
Save IAFahim/7713fd07d0b77c4cee044ed9712e794d to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
int a,aa,b,bb,i,till;
scanf("%d",&till);
for (int j = 0; j < till; j++)
{
scanf("%d %d",&a,&b);
if(a<b){
int temp=b;
b=a;
a=temp;
}
i=a%b;
aa=a;bb=b;
while(i!=0)
{
aa=bb;
bb=i;
i=aa%bb;
}
printf("%d %d\n",bb,a*b/bb);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment