code: def prime_gen() -> int:
      # credit to David Eppstein, Wolfgang Beneicke, Paul Hofstra
      
      D = {}
      yield 2
      for q in itertools.islice(itertools.count(3), 0, None, 2):
          p = D.pop(q, None)
          if p is None:
              D[q * q] = 2 * q
              yield q
          else:
              x = p + q
              while x in D:
                  x += p
              D[x] = p
docs: A generator for prime numbers starting from 2.