3
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$ Commented May 1, 2017 at 22:28
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jr Antalan
    Commented May 1, 2017 at 22:36

2 Answers 2

2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – Jr Antalan
    Commented May 1, 2017 at 22:59
  • $\begingroup$ Yes, just add the new term to the list (I changed the index on the interator). $\endgroup$
    – bill s
    Commented May 1, 2017 at 23:01
  • $\begingroup$ Got it bill. Thanks a lot for your answer and help. Till next time. $\endgroup$
    – Jr Antalan
    Commented May 1, 2017 at 23:03
2
$\begingroup$
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, "%"]
$\endgroup$
1
  • $\begingroup$ Thanks Jenny for your answer. I will try your implement your code. Thanks again. $\endgroup$
    – Jr Antalan
    Commented May 1, 2017 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.