# Division sieve operations in Mathematica

I am just wondering how to easily compute this problem using Mathematica.

What Percent of Even Integers are Divisible by either 6, 20, 28 or 70?

My purpose is to extend this to a finite number of factors greater than 4.

Thanks in advance for your help. I know a few Mathematica functions but I don't know what to use in this type of problem.

• This seems to be more a question of the underlying math than Mathematica. Could try a search for "inclusion-exclusion methods" to get a start. – Daniel Lichtblau May 1 '17 at 22:28
• Thanks for the comment Daniel. Indeed to solve the problem, we need to use Exclusion Inclusion Principle. However, computation is tedious for a finitely many facrors. That is why I am asking if there is a mathematica code available in order to get rid of such tedious computations. About your suggestion, I will try to search for that. Thanks again for the comment. I highly appreciate it. – Jr Antalan May 1 '17 at 22:36

Here is some Mathematica code to add up the appropriate LCMs:

list = {6, 20, 28, 70};
Total[Flatten[Table[(-1)^(i - 1)/LCM @@@ Subsets[list, {i}], {i, Length[list]}]]]
47/210


If you believe the comments at the linked Mathematics site, this will need to be multiplied by 2.

• Thanks for your answer bill. I just have a folow up question before trying the code and accept the answer as correct. I for instance I add another factor say 110. What I will do then is to add 110 on the list and change 4 with 5? Am I correct? – Jr Antalan May 1 '17 at 22:59
• Yes, just add the new term to the list (I changed the index on the interator). – bill s May 1 '17 at 23:01
• Got it bill. Thanks a lot for your answer and help. Till next time. – Jr Antalan May 1 '17 at 23:03
list = {6, 20, 28, 70};
S = Drop[Subsets[list], 1];
R = -2*Sum[(-1)^Length[S[[k]]]/LCM @@ S[[k]], {k, 1, Length@S}];
Print[R*100 // N, "%"]

• Thanks Jenny for your answer. I will try your implement your code. Thanks again. – Jr Antalan May 1 '17 at 23:01