Skip to content

Commit dcf7795

Browse files
committed
Create SieveOfEratosthenes.py
Version 1 : unoptimized
1 parent 12dbb6f commit dcf7795

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

SieveOfEratosthenes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
print 'Show prime numbers till: '
2+
x = int(raw_input())
3+
numlist = range(2,x+1)
4+
for num in numlist:
5+
p = 2
6+
while p < 50:
7+
if (p * num) in numlist:
8+
numlist.remove(p * num)
9+
p = p + 1
10+
print numlist
11+
print 'Prime numbers till {0} are {1}'.format(x, len(numlist))

0 commit comments

Comments
 (0)