10159 - GCD and LCM   

Description

Given two positive integer x and y, calculate the GCD (greatest common divisor) and LCM (least common multiple) of x and y.

 


Hint:

#include

int main()
{
        int x, y;
        scanf("%d %d", &x, &y);
        int xcp, ycp;
        int gcd;


        // x is not necessarily bigger than y
        xcp = x;
        ycp = y;
        while(xcp > 0 && ycp > 0){
                 /* calculate the gcd */
                 /* add your code here */
        }

        /* determine which one is gcd */
        /* add your code here */

        printf("GCD: %d\n", gcd);
        printf("LCM: %d\n", x*y/gcd);

        return 0;
}

 

Input

 Two positive integer x and y, where 0 < x,y < 10000.

Output

 GCD and LCM of x and y.

Sample Input  Download

Sample Output  Download

Tags




Discuss