Quantcast
Channel: Sieve of Eratosthenes - Finding Primes Python - Stack Overflow
Viewing all articles
Browse latest Browse all 28

Answer by SilentDirge for Sieve of Eratosthenes - Finding Primes Python

$
0
0

My implementation:

import mathn = 100marked = {}for i in range(2, int(math.sqrt(n))):    if not marked.get(i):        for x in range(i * i, n, i):            marked[x] = Truefor i in range(2, n):    if not marked.get(i):        print i

Viewing all articles
Browse latest Browse all 28

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>