Given two positive integer x and y, calculate the GCD (greatest common divisor) and LCM (least common multiple) of x and y.
Hint:
#includeint 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; }
Two positive integer x and y, where 0 < x,y < 10000.
GCD and LCM of x and y.