-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem7.py
More file actions
41 lines (29 loc) · 844 Bytes
/
Copy pathproblem7.py
File metadata and controls
41 lines (29 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import time
from mymodule import calculate_time
from mymodule import is_prime
#########################################################################3
def get_prime(n):
index = 1
count = 1 # already count 2 as prime
if n < 1:
return None
if n == 1:
return 2
while count < n:
index += 2
if is_prime(index):
count += 1
return index
#########################################################################3
@calculate_time
def main():
try:
f = open("10000prime.txt", "w")
for i in range(1, 10001):
f.write(str(get_prime(i)) + "\n")
except Exception as e:
print("Error:" + str(e))
finally:
f.close()
if __name__ == "__main__":
main()