Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #We want the 10,001th prime
  2. n = 10001
  3.  
  4. def Natural(x):
  5. while True:
  6. yield x
  7. x += 1
  8.  
  9.  
  10. primes = []
  11. isPrime = True
  12. i = 2
  13. while len(primes) < n:
  14. isPrime = True
  15. for j in range(2,int(i**(0.5)+1)):
  16. if i % j == 0:
  17. isPrime = False
  18. break
  19. if isPrime:
  20. primes.append(i)
  21. print(i)
  22. i += 1
  23.  
  24.  
  25. print(primes[n - 1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement