6.8 Enumerate all primes to n - bug in Python solution

#1

The basic solution has an off-by-one error. The outer loop should be for p in range(2, n + 1). Otherwise inputting a prime number to the function would exclude it from the output, which isn’t the behavior described by the comment at the top of the function (“up to and including n”) nor does it match the behavior of the improved function.

0 Likes

#2

Hi @robc,

Thanks for this report, and It is reported by others as well. Really appreciated for this and keep us know what you think we can improve then!

0 Likes