Fix bug in generate_previous_primes()