Given two positive integers x and y, compute their greatest common divisor (GCD) and least common multiple (LCM). The GCD of two numbers is the largest positive integer that can divide the numbers without a reminder. The LCM of two numbers is the smallest positive integer that can be divided by the two numbers without a reminder.
For example, if x=15 and y=50, you should print:
5 150
since the GCD of 15 and 50 is 5, and the LCM of 15 and 50 is 150.
Note that
1. This problem involves three files.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block. (Please choose c++ compiler)
Step 2. Check the results and debug your program if necessary.
function.h
#ifndef FUNCTION_H
#define FUNCTION_H
int gcd(int a,int b);
int lcm(int a,int b);
#endif
main.cpp
#include <stdio.h>
#include "function.h"
int main(void)
{
int x,y;
scanf("%d %d",&x,&y);
printf("%d %d",gcd(x,y),lcm(x,y));
return 0;
}
Two positive integer x and y, where 0<x,y<5000.
GCD and LCM of x and y, which are separated by a space.
Note that you DO NOT need to print ‘\n’ at the end of the output.