primal icon indicating copy to clipboard operation
primal copied to clipboard

Iterating primes in descending order

Open samuelpilz opened this issue 4 years ago • 1 comments

Hi, I have the usecase where I need to iterate primes of a sieve in descending order starting from some upper bound.

This example prints all primes below 100 in descending order

for prime in sieve.primes_from_desc(100) {
  println!("{}", p);
}

Is a function like this possible?

samuelpilz avatar Sep 09 '21 18:09 samuelpilz

It should be possible, yes. It could be a new iterator type, or we could try making SievePrimes doubled-ended, although that would require more complicated state.

cuviper avatar Sep 09 '21 18:09 cuviper