Couple more problems
This commit is contained in:
23
problem_7.py
Normal file
23
problem_7.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import math
|
||||
# find the 10001st prime number
|
||||
|
||||
def isPrime(number):
|
||||
prime = True
|
||||
i = 2
|
||||
while i < math.sqrt(number) + 1:
|
||||
if number % i == 0:
|
||||
prime = False # found a factor, not prime
|
||||
break
|
||||
else:
|
||||
i += 1
|
||||
|
||||
return prime
|
||||
|
||||
i = 1;
|
||||
primeCount = 1
|
||||
while (primeCount != 10001):
|
||||
if isPrime(i):
|
||||
primeCount += 1
|
||||
i += 1
|
||||
|
||||
print(i)
|
||||
Reference in New Issue
Block a user