Advertisement
onexiv

Riemann by Anthony David Pulse, Jr.

Jan 22nd, 2024 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import math
  2.  
  3. def is_prime(num):
  4. if num < 2:
  5. return False
  6. for i in range(2, int(num**0.5) + 1):
  7. if num % i == 0:
  8. return False
  9. return True
  10.  
  11. def generate_primes(start_x):
  12. prime_numbers = []
  13. x = start_x
  14. while x < 100000:
  15. if x % 2 == 0:
  16. x += 1
  17. continue
  18. elif math.sqrt(x) == math.floor(math.sqrt(x)+0.49):
  19. x += 1
  20. continue
  21. elif x % 7 == 0:
  22. x += 1
  23. continue
  24. elif x % 5 == 0:
  25. x += 1
  26. continue
  27. elif x % 3 == 0:
  28. x += 1
  29. continue
  30. # if (y + 2 <= x):
  31. prime_numbers.append(x)
  32. for i in prime_numbers:
  33. if i != x and x % i == 0:
  34. prime_numbers.remove(x)
  35. break
  36. x = x + 1
  37. return prime_numbers
  38.  
  39. # Example usage:
  40. start_x = 3
  41. prime_numbers0 = generate_primes(start_x)
  42. print(" ", len(prime_numbers0))
  43. # print(f"{prime_numbers0}")
  44. g = 0
  45. glist = []
  46. for i in prime_numbers0:
  47. if is_prime(i):
  48. g += 1;
  49. else:
  50. glist.append(i)
  51.  
  52. print(f"{glist}/{len(prime_numbers0)}")
  53.  
  54. start_x = 5
  55. prime_numbers1 = []
  56. prime_numbers1 = generate_primes(start_x)
  57. print(" ", len(prime_numbers1))
  58.  
  59. g = 0
  60. for i in prime_numbers1:
  61. if is_prime(i):
  62. g += 1;
  63.  
  64. print(f"{g}/{len(prime_numbers1)}")
  65.  
  66. print(prime_numbers0 == prime_numbers1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement