Question 1023732
 
Question:
Find how many positive integers with exactly four decimal digits, that is, positive integers between 1000 and 9999 inclusive, have the following properties: 
(a) are divisible by 5 or by 7 (inclusive or). 
(b) are divisible by 5. 
(c) are divisible by 7. 
(d) are not divisible by either 5 or 7. 
 
Solution:
We will need the inclusive/exclusive principles.
For example, we look for numbers divisible by 2 or 3 between 1 to 20.
Using integer arithmetic, i.e. discard fractions from quotients, we know that there are 20/3=6 divisible by 3, and 20/2=10 divisible by 2.
The quantity o f numbers divisible by 2 OR by 3 is NOT 6+10=16!
Why?  It's because 6 is divisible by both two and three, and its multiples have been counted twice.  So we must subtract 20/6=3 from 16 to get the right answer, namely 13, or 6+10-3=13, using the inclusion/exclusion principle.
 
Now for the pool of numbers between 1000 and 9999, we calculate the following:
(a) are divisible by 5 or by 7 (inclusive or). 
Divisible by 5: 9999/5-1000/5=1999-200=1799
Divisible by 7: 9999/7-1000/7=1428-142=1286
Divisible by 35: 9999/35-1000/35=285-28=257
So 
Divisible by 5 OR 7 = 1799+1286-257=2828
 
(b) are divisible by 5. 
See part (a) 

(c) are divisible by 7. 
See part (a)
 
(d) are not divisible by either 5 or 7. 
The pool of numbers is from 1000 to 9999, namely 9000 numbers, out of which 2828 are divisible by either 5, or 7 or both.  The difference of 9000 and 2828 would therefore be those that are divisible neither by 5 nor 7.