Sign in $ create-account
~/problems ~/discussion ~/contests ~/submission
← ~/problems
P2007

Count the Primes

Medium
// Description
Given an integer n, count how many prime numbers are less than or equal to n.
// Input
A single integer n (1 <= n <= 10^6).
// Output
The number of primes not greater than n.
// Hint
A sieve of Eratosthenes counts all primes up to n in O(n log log n).
// Samples
Sample Input
10
Sample Output
4
// Problem Info
DifficultyMedium
Acceptance80%
Time Limit1000 ms
Memory Limit65536 KB
Accepted8