Header Ads Widget

python program on sieve of eratosthenes

 Code:-


# function of the sieve of eratosthenes
def SOE(n):
mylist=[]
for i in range(2,n+1):
if i not in mylist:
print(i)
for j in range(i*i,n+1,i):
mylist.append(j)
# function callling
n=int(input("Enter a number"))
SOE(n)

Output:-

Enter a number15
2
3
5
7
11
13

Python program to find fiboonacci series



Post a Comment

0 Comments