Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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?
- #isPrime algorithm from MIT 6.00x course notes
- def isPrime(n):
- '''check if integer n is a prime'''
- # range starts with 2 and only needs to go up the square-root of n
- for x in range(2, int(n**0.5)+1):
- if n % x == 0:
- return False
- return True
- count = 0
- i = 2
- while count < 10001:
- if isPrime(i):
- count += 1
- i += 1
- print i-1
Advertisement
Add Comment
Please, Sign In to add comment