Minimum positive integer divisible by 1 to 20

Source: Internet
Author: User
Returns the smallest positive integer that can be divisible by numbers ranging from 1 to 20. The most intuitive method is to obtain the minimum public multiple of the 20 numbers from 1 to 20. Evaluate the minimum public multiples of n numbers. take the numbers a, B, and c as an example. Their minimum public multiples are equal to: first obtain the minimum public multiples m of a and B, then the minimum public multiples of m and c are the minimum public multiples of three numbers.

Returns the smallest positive integer that can be divisible by numbers ranging from 1 to 20. The most intuitive method is to obtain the minimum public multiple of the 20 numbers from 1 to 20.

Evaluate the minimum public multiples of n numbers. take the numbers a, B, and c as an example. Their minimum public multiples are equal to: first obtain the minimum public multiples m of a and B, then the minimum public multiples of m and c are the minimum public multiples of three numbers.

Evaluate the minimum public multiples of two numbers a and B. first extract the larger one, such as a, and then use k * a to test whether the smaller one can be divisible, k is the natural number k * a starting from 1

Int get_lcm (int a, int B) {if (a = B) {return a;} int bigger =
     
  

Another better method is to take n as an example.

2, 3, 4, 5, 6, 7, 8, 9, 10 (1 does not make any sense, ignore it)

Decompose these numbers into prime factors:

2, 3, 2*2, 5, 2*3, 7, 2*2*2, 3*3, 2*5

These prime numbers are 2, 3, 5, and 7 respectively.

The final answer can be expressed:

2 ^ a * 3 ^ B * 5 ^ c * 7 ^ d (where, x ^ y indicates the power y of x)

The English letters indicate the maximum number of times the prime factor appears in the expression obtained when the prime factor is decomposed.

Prime factor 2 appears three times at most in 8 = 2*2*2, so a is 3.

Similarly, we can get 2 ^ 3*3 ^ 2*5 ^ 1*7 ^ 1 = 2520.

This article is available at http://www.nowamagic.net/librarys/veda/detail/939.

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.