/ Published in: Python
Function (algorithm) that returns all prime numbers up to n.
- def E_sieve(n):
- for p in range(2, n+1): # fils the list with numbers from 2 up to n
- for p in range(2, int(floor(n)-1)):
- if A[p]!=0: # cheks if p had been eliminated in any of the previous passess
- while j<=n-2:
- A[j]=0 # marks element as eliminated
- # copying the remaining elements from list A into list L
- for p in range(2, n-1):
- if A[p]!=0:
- return L
You need to login to post a comment.