1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2025 Johanna Sörngård
// SPDX-License-Identifier: MIT OR Apache-2.0
use cratesieve;
/// Returns an array of size `N` where the value at a given index is how many primes are less than or equal to the index.
///
/// Sieves primes with [`sieve`](crate::sieve()) and then counts them.
///
/// # Example
///
/// Basic usage
///
/// ```
/// # use const_primes::prime_pi;
/// const COUNTS: [usize; 10] = prime_pi();
/// assert_eq!(COUNTS, [0, 0, 1, 2, 2, 3, 3, 4, 4, 4]);
/// ```
pub const