This commit is contained in:
Reese Wells
2018-07-29 17:25:09 -04:00
commit 47c752ff65
6 changed files with 164 additions and 0 deletions

38
mediumfindprime.py Normal file
View File

@@ -0,0 +1,38 @@
from timer import timing_function
def isprime(number):
"""
checks if a number is prime by dividing it into every odd number less than
number // 2
"""
current_num = 3
if number % 2 == 0:
return False
while current_num <= number // 2:
if number % current_num == 0:
return False
current_num += 2
return True
@timing_function
def findprimesto(primecap):
for i in range(0, primecap):
isprime(i)
@timing_function
def findxprimes(x):
primelist = []
current_num = 2
while len(primelist) < x:
if isprime(current_num):
primelist.append(current_num)
current_num += 1
return primelist