All tasks
Mediummathsievearrays

Count Primes

Time limit 2 s · Memory 64 MBAcceptance: 100.0%Solved by: 1

Statement

You are given an integer n. Print how many prime numbers lie between 1 and n inclusive.

Examples

Example 1
Input
10
Output
4
Example 2
Input
1
Output
0

Constraints

  • 1 ≤ n ≤ 10^6
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.