Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import math
  2. startingPrimes = [2,3, 5, 7, 11, 13, 17, 19]
  3. for times in range (2):
  4. primeList = []
  5. numbersToBeTested = 0
  6. for _ in range (startingPrimes[len(startingPrimes)-1]**2):
  7. primeList.append(_ + 2)
  8. print ()
  9. numbersToBeTested = startingPrimes[len(startingPrimes)-1]**2
  10. print (numbersToBeTested)
  11. divisor = 0
  12. term = 0
  13. dividend = 0
  14. position = 0
  15.  
  16. while divisor < math.sqrt(len(primeList)):
  17. term = 0
  18. divisor = startingPrimes[position]
  19. dividend = primeList[position]
  20. while term + 1 < len(primeList):
  21.  
  22. term = term + 1
  23. if primeList[term] % divisor == 0:
  24. if primeList[term] != divisor:
  25. primeList.remove(primeList[term])
  26. position = position + 1
  27. startingPrimes = primeList
  28.  
  29. for termOfList in range (len(primeList)):
  30. print (primeList[termOfList])
  31. print ("How many primes: " + str(len(primeList)))
  32. print ("10001st prime: " + str(primeList[10000]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement