The smallest reciprocal subset algorithm

Given a set A of n natural numbers, we define a nonempty subset B consisting of as few elements as possible, so that their GCD is 1 and displays its size.

For example:
5
6 10 12 15 18

gives the output "3", and:

5
2 4 6 8 10

equals "NONE" since a subset cannot be defined.

So this seems really basic, but I still stick to it. My thoughts on this are as follows: we know that the presence of multiples of a certain number already present in the set is useless, since their divisors are the same time as the coefficient k, and we are going for the smallest subelement. Therefore, for any n i, we remove any kn i , where k is a positive int from further calculations.

That I'm stuck, though. What should I do next? I can only think of a dumb, brute force attempt to try if there is already a 2-element subset, then 3-elem and so on. What should I check to identify it in a smarter way?

+4
source share
2 answers

, A, B ( ) D. D - : A, B → D , D → A, B

D = 1, - 2. , D, D = 1. 3? , : D: D1 D2 , GCD (D1, D2) = 1. ? , As Bs Ds, a 2 3 . ?

100%, .

, . ( N 2).

, , , . , , .

( ): GCD (a1, a2,... aN) GCD. , ( ).

. . , .

https://cs.stackexchange.com/questions/10249/finding-the-size-of-the-smallest-subset-with-gcd-1

+1

, , . , .

: , .

, .

, , , , . , " "?

. :
1. . 2. .
3. .

, , , .

+1

All Articles