View Code of Problem 59

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>

char a[105], b;

int gcd(int a, int b)
{
    if (a % b == 0) {
        return b;
    }
    
    return gcd(b, a % b);
}

int main()
{
    int s, t;
    while (scanf("%d%d", &s, &t) != EOF) {
        int p = gcd(s, t);
        printf("%d %d\n", s * t / p, p);
    }
}

Double click to view unformatted code.


Back to problem 59