We begin by recalling that every 4-digit natural number lies between 1000 and 9999, inclusive. Hence the total count of 4-digit numbers is obtained from
9999−1000+1=9000.
Let us denote by
A={4-digit numbers divisible by 7},
B={4-digit numbers divisible by 3}.
Our aim is to count the 4-digit numbers which are in neither set, that is, numbers which belong to the complement of A∪B within the universe of 4-digit numbers.
Using the principle of inclusion-exclusion, we have
∣A∪B∣=∣A∣+∣B∣−∣A∩B∣,
and therefore
Required count=9000−∣A∪B∣.
We now compute the three quantities ∣A∣,∣B∣ and ∣A∩B∣ one by one.
Counting the multiples of 7
The smallest multiple of 7 not less than 1000 is found by dividing and taking the ceiling:
⌈71000⌉=143,7×143=1001.
The largest multiple of 7 not exceeding 9999 is obtained via the floor:
⌊79999⌋=1428,7×1428=9996.
Thus the integers 143,144,…,1428 give all required multiples, so
∣A∣=1428−143+1=1286.
Counting the multiples of 3
Proceeding likewise, the smallest multiple of 3 not less than 1000 is
⌈31000⌉=334,3×334=1002,
and the largest such multiple is
⌊39999⌋=3333,3×3333=9999.
Hence the numbers 334,335,…,3333 supply every 4-digit multiple of 3, giving
∣B∣=3333−334+1=3000.
Counting the common multiples of 7 and 3
A number divisible by both 7 and 3 must be divisible by their least common multiple, lcm(7,3)=21.
The smallest multiple of 21 not less than 1000 is
⌈211000⌉=48,21×48=1008,
while the largest is
⌊219999⌋=476,21×476=9996.
This yields the integers 48,49,…,476, so
∣A∩B∣=476−48+1=429.
Applying inclusion-exclusion
Substituting the obtained values, we have
∣A∪B∣=1286+3000−429=3857.
Finishing the calculation
Finally, the count of 4-digit numbers which are neither multiples of 7 nor multiples of 3 is
9000−3857=5143.
So, the answer is 5143.