View Code of Problem 59

#include "stdlib.h"
#include "iostream"
#include "string.h"
#include "math.h"
int main()
{
	int a, b; int x, y;
	scanf("%d %d", &a, &b);
	for (int i=1;i<=a*b;i++)
	{
		if (i%a == 0 && i%b == 0)
		{
			x = i;
			break;
		}
	}
	for (int i = a>b?b:a;i>0; i--)
	{
		if (a%i == 0 && b%i == 0)
		{
			y = i;
			break;
		}
	}
	printf("%d %d", x, y);
	system("pause");
}

Double click to view unformatted code.


Back to problem 59