-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject_7.py
More file actions
executable file
·46 lines (35 loc) · 850 Bytes
/
Project_7.py
File metadata and controls
executable file
·46 lines (35 loc) · 850 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
46
#!/usr/bin/python
def isPrime(n):
if n <= 1:
return False
elif n <= 3:
return True
elif n % 2 == 0 or n % 3 == 0:
return False
# End if/else block
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
# End if
i = i + 6
# End while
return True
# End def
def main():
prime_counter = 0
cur = 0
while prime_counter <= 10000:
cur += 1
if isPrime(cur):
prime_counter += 1
# End if
# End while
print "The 10001st prime number is: %s" % cur
# End def
if __name__ == "__main__":
main()
# End if
# Goal:
"""By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?"""