hi , i am having difficulty in implementing the basic mathematic principle of inclusion-exclusion. I want to find the no. of numbers in a range from 1 to N which are divisible by another set of numbers where size of set <= 15.
Now the problem i am facing is that how do i consider the loops for calculating pair wise, three -wise , four - wise etc, because if the size is 2 i need to calculate a1+a2-a1*a2. ,where a1 is the no. of elements in set i to N divisible by 1st no of the second set , and so on, thus 1 loop
a1+a2+a3-(a1*a2) -(a1*a3)-(a2*a3)-(a1*a2*a3) so 2 loops .
similarly for 4 , there should be 4 loops and so on thus rending the programme very lenghty and inefficient , so how should i implement it?