View Code of Problem 59

# include<stdio.h>
int f(int a,int b)
{
    int t,i;
    if(a>b)
    {
        t = a;
        a = b;
        b = t;
    }
    for(i=1;i<=a;++i)
    {
        if(a%i==0&&b%i==0)
        {
            t = i;
        }
    }
    return t;
}
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d %d",a*b/f(a,b),f(a,b));
    return 0;
}

Double click to view unformatted code.


Back to problem 59