-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprob_07.py
More file actions
45 lines (34 loc) · 731 Bytes
/
Copy pathprob_07.py
File metadata and controls
45 lines (34 loc) · 731 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
42
43
44
45
# Project Euler Problem-7, python3
"""
@author: Rohit Maurya
"""
from timeit import default_timer as timer
start = timer()
def isprime(n):
"""Returns True if n is prime."""
if n == 2:
return True
if n == 3:
return True
if n % 2 == 0:
return False
if n % 3 == 0:
return False
i = 5
w = 2
while i * i <= n:
if n % i == 0:
return False
i += w
w = 6 - w
return True
count = 0
for n in range(2, 1000000):
if isprime(n):
count = 1+ count
if count == 10001:
print(n)
break
end = timer()
time_taken = (end-start)*1000
print("Time taken to run this program: %d ms"%time_taken)