Finding Prime number using Sieve Of Eratosthenes
def
SieveOfEratosthenes(n)
:
prime = [
True
for
i
in
range
(n + 1)]
p = 2
while
p * p <= n:
if
prime[p] ==
True
:
for
i
in
range
(p * p, n + 1, p):
prime[i] = False
p += 1
for
p
in
range
(2, n + 1):
if
prime[p]:
print
(p)
a = int(input())
SieveOfEratosthenes(a)
Please Enter the Range of the Number:
Read Number
loop
Final answer
p=
2
You Enterd :
nothing
p*p=4
value of p incresed by 1.
PRIME NUMBERS ARE:
Reset