This commit is contained in:
ducoterra
2018-08-14 00:20:31 -04:00
parent 47c752ff65
commit 0a652e8f4c
6 changed files with 142 additions and 7 deletions

39
threadfindprime.py Normal file
View File

@@ -0,0 +1,39 @@
from addit import timeit, processit
@processit
def isprime(number, primelist):
"""
checks if a number is prime by finding dividing it by every other prime
below floor(number / 2)
"""
print(primelist)
for prime in primelist:
if prime <= number // 2 and number % prime == 0:
return False
return True
@timeit
def findxprimes(x):
"""
finds numprimes count of prime numbers
"""
primelist = [2]
testnum = 3
cores = 4
usedcores = 0
while len(primelist) < x:
usedcores += 1
if isprime(testnum, primelist) and usedcores < 4:
primelist.append(testnum)
usedcores -= 1
testnum += 2
return primelist
findxprimes(5)