###### Leetcode 204. Count Primes

Description:
Count the number of prime numbers less than a non-negative number, n.

http://www.cnblogs.com/zfyouxi/p/4907294.html

class Solution {
public:
int countPrimes(int n) {
vector<bool> prime(n, true);
prime[0] = false, prime[1] = false;
for (int i = 0; i < sqrt(n); ++i) {
if (prime[i]) {
for (int j = i*i; j < n; j += i) {
prime[j] = false;
}
}
}
return count(prime.begin(), prime.end(), true);
}
};

#### LeetCode 204. Count Primes（C++版）

2017-03-30 17:04:12

#### LeetCode 204 - Count Primes

2015-04-27 15:33:15

#### Python 刷题日记：LeetCode 204: Count Primes

2017-06-28 21:13:19

#### 【LeetCode-面试算法经典-Java实现】【204-Count Primes（统计质数）】

2015-08-27 06:30:01

#### LeetCode 204 Count Primes（质数计数）（*）

2016-02-01 11:25:24

#### LeetCode 204:Count Primes

2015-05-08 18:40:26

#### leetcode 204: Count Primes

2015-04-29 08:33:10

#### 204. Count Primes [easy] (Python)

2016-05-05 12:48:13

#### [LeetCode-204] Count Primes（0~n 有多少个质数—4种方法求解）

2015-10-23 15:18:31

#### 204. Count Primes (java)

2017-04-02 21:16:30

## 不良信息举报

Leetcode 204. Count Primes