Maximum male factor, least common multiple, factorization

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.