The maximum common factor is calculated by using the least common multiple method, and the formula is used to seek it.
Maximum male factor * least common multiple = two number product
The maximum common factor can be solved using recursion and non-recursion, the factorization is basically using a value less than the input number as a divisor, to divide the input value, if you can divide it as a factor, the faster solution is to find less than the number of all prime numbers, and try to see if it is divisible, To find prime numbers is another problem, refer to Eratosthenes filtering for prime numbers.
First, to seek the maximum common factor, least common multiple
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int m,n,r;
int s;
printf ("Please enter two numbers:");
scanf ("%d%d", &m,&n);
S=m*n;
while (n!=0)
{
r=m%n;
M=n;
N=r;
}
printf ("Max Common multiple:%d\n", m);
printf ("Minimum number of conventions:%d\n", s/m);
return 0;
}
Second, factoring
void Resolve (int n)
{
int i;
printf ("%d=", N);
for (i=2;i*i<=n;)
{
if (n%i==0)
{
printf ("%d*", I);
N/=i;
}
Else
i++;
}
printf ("%d\n", N);
}
This article from "Youth, do not look back" blog, please be sure to keep this source http://zhangye.blog.51cto.com/9858037/1607559
Maximum male factor, least common multiple, factorization