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

Answer by Pythoscorpion for Sieve of Eratosthenes - Finding Primes Python

$
0
0

i think this is shortest code for finding primes with eratosthenes method

def prime(r):    n = range(2,r)    while len(n)>0:        yield n[0]        n = [x for x in n if x not in range(n[0],r,n[0])]print(list(prime(r)))

Viewing all articles
Browse latest Browse all 28

Trending Articles



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