DEV Community

ETHAN LEONG _
ETHAN LEONG _

Posted on

Prime Function

def get_primes(n):
primes = []
candidate = 2
while len(primes) < n:
for p in primes:
if candidate % p == 0:
break
else:
primes.append(candidate)
candidate += 1
return primes

Top comments (0)