204. Count Primes Medium
1/**
2 * [204] Count Primes
3 *
4 * Given an integer n, return the number of prime numbers that are strictly less than n.
5 *
6 * Example 1:
7 *
8 * Input: n = 10
9 * Output: 4
10 * Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
11 *
12 * Example 2:
13 *
14 * Input: n = 0
15 * Output: 0
16 *
17 * Example 3:
18 *
19 * Input: n = 1
20 * Output: 0
21 *
22 *
23 * Constraints:
24 *
25 * 0 <= n <= 5 * 10^6
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/count-primes/
31// discuss: https://leetcode.com/problems/count-primes/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn count_primes(n: i32) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_204() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.