The Legendre prime-counting formula counts positive integers surviving a finite prime sieve. For , put and let be the primes at most . By inclusion-exclusion principle, the number of positive integers at most divisible by none of these primes is
The empty product is . Every composite number at most has a prime factor at most , so the survivors are precisely and the primes between and . Consequently
For , the sieving primes are , and
As a direct check, the primes are .