Implement Function to Return First n Prime Numbers
PinterestData Scientist · OnsiteLast updated
This question evaluates algorithmic problem-solving and basic number-theory competency by requiring generation of prime numbers with attention to correctness and performance characteristics.
Scenario
Quick algorithm screen to gauge Python fluency.
Question
Implement a Python function that returns the first n prime numbers.
Hints
An optimized sieve or trial-division with memoization keeps it simple and efficient.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.