pub fn sieve_to_n(limit: usize) -> Vec<usize> {
        // Create a mutable boolean vector to represent the sieve
        let mut primes = vec![true; limit + 1];

        // Mark all non prime numbers as false
        mark_false_if_not_prime(limit, &mut primes).unwrap();

        // Enumerate and filter_map primes for true values and return them
        primes
            .iter()
            .enumerate()
            .filter_map(|(n, &is_prime)| if is_prime { Some(n) } else { None })
            .collect()
    }
/// Calculate primes up to limit using the Sieve of Eratosthenes.
Calculate primes up to limit using the Sieve of Eratosthenes.
Calculate primes up to limit using the Sieve of Eratosthenes .
pub fn sieve_to_n(limit: usize) -> Vec<usize> {
        // Create a mutable boolean vector to represent the sieve
        let mut primes = vec![true; limit + 1];
        // Mark all non prime numbers as false
        mark_false_if_not_prime(limit, &mut primes).unwrap();
        // Enumerate and filter_map primes for true values and return them
        primes
            .iter()
            .enumerate()
            .filter_map(|(n, &is_prime)| if is_prime { Some(n) } else { None })
            .collect()
    }
pub fn sieve_to_n ( limit : usize ) -> Vec < usize > { // Create a mutable boolean vector to represent the sieve let mut primes = vec ! [ true limit 1 ] ; // Mark all non prime numbers as false mark_false_if_not_prime ( limit , & mut primes ) . unwrap ( ) ; // Enumerate and filter_map primes for true values and return them primes . iter ( ) . enumerate ( ) . filter_map ( | ( n , & is_prime ) | if is_prime { Some ( n ) } else { None } ) . collect ( ) }
Calculate primes up to limit using the Sieve of Eratosthenes.
Calculate primes up to limit using the Sieve of Eratosthenes .
limit
usize
limit
usize