Paste Search Dynamic
Recent pastes
primes
  1. import itertools
  2. import numpy as np
  3. def primes(n):
  4.     sieve = [true] * n
  5.     for i in range(3, int(n ** 0.5) + 1, 2):
  6.         if sieve[i]:
  7.             sieve[i * i::2 * i] = [false] * ((n - i * i - 1) // (2 * i) + 1)
  8.     return [2] + [i for i in range(3, n, 2) if sieve[i]]
  9.  
  10.  
  11. cnt = 0
  12. pr = np.array(primes(89001))
  13. w = np.arange(22001, 89001)
  14. w = np.setdiff1d(w, pr)
  15. #rr = np.multiply.outer(pr[pr<2966], pr[pr<2966]).flat
  16. rr = np.multiply.outer(pr[pr<44501], pr[pr<298])
  17. w = np.setdiff1d(w, rr.flat)
  18. np.fill_diagonal(rr, 89001)
  19. rr = rr[rr<44501]
  20. print(w.size)
  21. print(rr.size)
  22.  
Parsed in 0.008 seconds