# Third Week analysis program problem

Source: Internet
Author: User

`1 usingSystem; 2 usingSystem.Collections.Generic; 3 usingSystem.Text; 4    5 namespaceFindthenumber6 {  7      class Program8      {  9           Static voidMain (string[] args)Ten           {   One                int[] RG = A{2,3,4,5,6,7,8,9,Ten, One, A, -, -, the, -, -,   -                 -, +, -, +, A, at, -, -, -, -, -, in, -, to};  -     the                 for(Int64 i =1; i < Int64.maxvalue; i++)   -                {   -                     intHit =0;  -                     intHit1 =-1;  +                     intHit2 =-1;  -                      for(intj =0; (J < RG. Length) && (hit <=2); J + +)   +                     {   A                           if((i% rg[j])! =0)   at                           {   -hit++;  -                                if(hit = =1)   -                                {   -Hit1 =J;  -                                }   in                                Else if(hit = =2)   -                                {   toHit2 =J;  +                                }   -                                Else   the                                      Break;  *     \$                           }  Panax Notoginseng                     }   -     the                     if(hit = =2) && (hit1 +1==hit2))  +                     {   AConsole.WriteLine ("found {0}", i);  the                     }   +     -                }   \$           }   \$      }   -}`

The above is the given source code

What is the number of conditions that the program is looking for?

The topic is looking for the number of adjacent two numbers that cannot be divisible by 2 to 31 and divisible by all other numbers. Note: It is not difficult to see the true purpose of this procedure by the For loop.

Two. Does such a number exist? What is the minimum number that meets this condition?

Such a number exists.

First, for the 30 numbers from 2 to 31, we can divide them into two groups. The first group, 2 to 15, because 2 to 15 of twice times in 16 to 30, divisible by the large data must be divisible by her factor, therefore, we find the smallest eligible data, should be in 15 to 31 to remove the smallest two adjacent numbers, namely 16 and 17.

Second, we divide each number into the smallest factor multiplication, example, 8=2*2*2,9=3*3 and so on, to get the smallest data that satisfies the condition, the least factor should be used to combine all the data. For example, 8=2*4,2 and 4 are not needed. In the above program, as long as I can be divisible by 8, I can divide 2 and 4.

Last, finally is to discuss the problem can not be divisible by 16, 17, the second part of all the factors are listed, to get 8, at least 3 2, to get 27 at least 3 3, to get 25, at least 2 5, the rest of the vegetarian factor is enough to just one.

So, the combination of the least factor we get is: 2*2*2,3*3*3,5*5,7,11,13,17,19,23,29,31. Multiply them to get the minimum number of compliant data: 2123581660200

Three. How long do you expect to be able to output the first result when running this program on a computer?  Time accurate to minute (Computer Configuration: Single core Cpu4.0ghz, memory and hard disk resources sufficient) 3. 3-4 minutes

4. The integration of two or more complete compute engine (cores) multicore computers in a single processor can perform several operations at the same time, greatly improving execution speed.

Third Week analysis program problem

Related Keywords:

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.