pub fn primes(limit: usize) -> Vec<u32> {
    let sqrt = (limit as f64).sqrt().ceil() as usize;
    let mut res: Vec<u32> = Vec::with_capacity(sqrt);
    let mut sieve = vec![false; limit+1];
    if limit < 2 {
        return res;
    }
    for candidate in 2..limit + 1 {
        if sieve[candidate] {
            continue;
        }
        res.push(candidate as u32);
        let mut composite = 2 * candidate;
        while composite <= limit {
            sieve[composite] = true;
            composite += candidate
        }
    }
    res
}
/// Returns all primes less than or equal to limit in a vector
Returns all primes less than or equal to limit in a vector
Returns all primes less than or equal to limit in a vector
pub fn primes(limit: usize) -> Vec<u32> {
    let sqrt = (limit as f64).sqrt().ceil() as usize;
    let mut res: Vec<u32> = Vec::with_capacity(sqrt);
    let mut sieve = vec![false; limit+1];
    if limit < 2 {
        return res;
    }
    for candidate in 2..limit + 1 {
        if sieve[candidate] {
            continue;
        }
        res.push(candidate as u32);
        let mut composite = 2 * candidate;
        while composite <= limit {
            sieve[composite] = true;
            composite += candidate
        }
    }
    res
}
pub fn primes ( limit : usize ) -> Vec < u32 > { let sqrt = ( limit as f64 ) . sqrt ( ) . ceil ( ) as usize ; let mut res : Vec < u32 > = Vec :: with_capacity ( sqrt ) ; let mut sieve = vec ! [ false limit 1 ] ; if limit < 2 { return res ; } for candidate in 2 .. limit + 1 { if sieve [ candidate ] { continue ; } res . push ( candidate as u32 ) ; let mut composite = 2 * candidate ; while composite <= limit { sieve [ composite ] = true ; composite += candidate } } res }
Returns all primes less than or equal to limit in a vector
Returns all primes less than or equal to limit in a vector
limit
usize
limit
usize