[Sieve]: Update content.md for Comprehension Approach (#3865)

Added language about the disallowed `%` operator to the Comprehensions approach.
This commit is contained in:
BethanyG
2025-02-14 11:56:08 -08:00
committed by GitHub
parent c99a16e837
commit 664f1dbd91

View File

@@ -27,7 +27,8 @@ def primes(limit):
if all(number % divisor != 0 for divisor in range(2, number))]
```
This second example using a `list-comprehension` with `all()` is certainly concise and _relatively_ readable, but the performance is again quite poor.
This second example using a `list-comprehension` with `all()` is certainly concise and _relatively_ readable, but it uses **`%`** (_which the instructions ask you not to use_) and the performance is again quite poor.
This is not quite a fully nested loop (_there is a short-circuit when `all()` evaluates to `False`_), but it is by no means "performant".
In this case, scaling with input size is intermediate between linear and quadratic, so not quite as bad as the first example.