Sectionย 2. Chapterย 3
single
Challenge: Prime Number Generator
Swipe to show menu
Task
Swipe to start coding
Write a generator function primes_up_to(n) that yields all prime numbers less than or equal to n.
The function must:
- Yield numbers in ascending order, starting from the first prime number.
- Only yield numbers that are prime and less than or equal to
n. - Stop yielding values after reaching
n.
Solution
Everything was clear?
Thanks for your feedback!
Sectionย 2. Chapterย 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat