Forgot to add one to pp in parallel implementation.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-03-09 17:30:51 +01:00
parent f45932e188
commit 80f9cc855d

View File

@ -62,7 +62,7 @@ pub fn is_prime_mem(n:u64, primes:&VecDeque<u64>) -> bool
{ {
let limit = (n as f64).sqrt() as u64; let limit = (n as f64).sqrt() as u64;
let pp = primes.partition_point(|x| *x < limit); let pp = primes.partition_point(|x| *x < limit);
//let composite = primes.par_iter().take(pp).any(|x| n % *x == 0); //let composite = primes.par_iter().take(pp+1).any(|x| n % *x == 0);
let composite = primes.iter().take(pp+1).any(|x| n % *x == 0); let composite = primes.iter().take(pp+1).any(|x| n % *x == 0);
return !composite; return !composite;
} }