View Code of Problem 59

#include<stdio.h>
int main() {
	int a, b;
	int r1, r2;
	int result;
	scanf("%d %d", &a, &b);
	if (a > b) {
		int temp = a;
		a = b;
		b = temp;
	}
	r1 = a; r2 = b;
	while (r1 != 0 && r2 != 0) {
		r1 = r2 % r1;
		if (r1 == 0)result = r2;
		else {
			r2 = r1 % r2;
			if (r2 == 0)result = r1;
		}
	}
	printf("%d %d", a / result * b, result);
	return 0;
}

Double click to view unformatted code.


Back to problem 59