This question evaluates a candidate's ability to implement scalable prime generation and related algorithmic optimization, including algorithm selection, time and memory complexity reasoning, edge-case handling, and verification via unit tests.
Write a function first_n_primes(n) that returns the first n prime numbers in ascending order. Constraints: