Maths WorkshopMaths problems with full solutions
Exercise 1004Combinatorics › Inclusion-exclusionL1Added 3 Nov 2026

The sieve of Eratosthenes as IE

#IE#sieve#primes

Statement

Use IE to count primes up to 3030.

Hint

Apply the sieve: exclude multiples of 2,3,52,3,5 (primes up to 30\sqrt{30}), then handle the primes 2,3,52,3,5 separately.

Show solutionHide solution

Solution

Multiples of 2,3,52,3,5 up to 3030. From IE: 15+10+6−5−3−2+1=2215+10+6-5-3-2+1=22.

Not divisible. 30−22=830-22=8 integers not divisible by 2,3,52,3,5 up to 3030: 1,7,11,13,17,19,23,291,7,11,13,17,19,23,29.

Primes. Excluding 11, and adding 2,3,52,3,5: 7+3=107+3=10 primes.

Conclusion. π(30)=10\pi(30)=10.