View Code of Problem 59

#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 100
int main()
{
	int a, b, t, c, d, gys, gbs;
	scanf("%d %d", &a, &b);
	if (a < b)
	{
		t = b;
		b = a;
		a = t;
	}
	c = a, d = b;
	gys = a % b;
	if (gys == 0)
	{
		gbs = a * b / gys;
		printf("%d %d", gbs, gys);
	}
	else
	{
		while (gys)
		{
			a = b;
			b = gys;
			gys = a % b;
		}
		gys = b;
		gbs = c * d / gys;
		printf("%d %d", gbs, gys);
	}

}

Double click to view unformatted code.


Back to problem 59