primal
primal copied to clipboard
Iterating primes in descending order
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?
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.