Question DSA-MATH-0041
MediumWhat is the output of this code?
def sieve(n):
p = [True] * (n + 1)
p[0] = p[1] = False
for i in range(2, int(n ** 0.5) + 1):
if p[i]:
for j in range(i * i, n + 1, i):
p[j] = False
return [i for i in range(n + 1) if p[i]]
r = sieve(50)
print(len(r), r[-1])
- A.
15 47
- B.
16 50
- C.
Sign up free to see the answer and a step-by-step explanation.