First give the source code, explained below.
#include <stdio.h>
void Main ()
{
int a,b,c,d; //define four variables
scanf ("%d,%d", &a,&b);
D=a*b; //Find out the product of two positive integers
while (b!=0)
{
C=a%b; //focus is here, a lot of people do not understand, and then look down
A=b;
B=c;
}
printf ("Greatest common divisor is%d, max Common multiple is%d\n", A, (d/a));
}
The method of least common multiple: a*b/greatest common divisor
So we find out greatest common divisor let D come apart.
The simplest is to use the Euclidean method, known in the West as Euclid's algorithm. Do not know Baidu a bit. Give the connection.
Http://baike.baidu.com/link?url=XfjUEUXTY7vO1H9NOQTWmRC8ACvW5miDkW16AZ5IrWhA3dQPiFYzPMcC-EI7Li0z0Qt-obgvLLxy6JSZffkena
Simply put: From the first start to calculate the a%b, the remainder C is obtained. The second time to assign the divisor B to a, let the original divisor to do dividend, the remainder of the divisor. If there is greatest common divisor, the last divisor is greatest common divisor. The greatest common divisor is calculated by dividing the product of two integers by greatest common divisor to obtain the least common multiple.
C language calculates the greatest common divisor and maximum common multiple of two positive integers