Question DSA-MATH-0008
MediumWhat is the output of this code?
n = 20
is_p = [True] * n
is_p[0] = is_p[1] = False
for i in range(2, int(n ** 0.5) + 1):
if is_p[i]:
for j in range(i * i, n, i):
is_p[j] = False
print([i for i in range(n) if is_p[i]])
- A.
[1, 2, 3, 5, 7, 11, 13, 17, 19]
- B.
[2, 3, 5, 7, 11, 13, 17, 19]
- C.
[3, 5, 7, 11, 13, 17, 19]
- D.
[2, 3, 5, 7, 9, 11, 13, 15, 17, 19]
Sign up free to see the answer and a step-by-step explanation.