Count the Primes
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
Count how many prime numbers there are below a given number n, where n can be several million. There are four below ten: two, three, five and seven. Explain a method that is much faster than testing each number on its own.
What a strong answer covers
- A method that rules numbers out in bulk instead of testing each.
- Where the crossing out can safely begin for each prime.
- When to stop and which small numbers need special treatment.
- Time and memory compared with the one-by-one approach.
Common mistake: Crossing out multiples of every number, not just the primes, which repeats a lot of work for nothing.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud