Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/extensible-prime-generator/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / extensible-prime-generator / oracle.py` 18 lines ยท 797 bytes Raw Blame History 1 # Independent reference for "Extensible prime generator" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 import itertools 4 def primes(): 5 # incremental sieve: each composite maps to the primes that will strike it 6 d = {} 7 for q in itertools.count(2): 8 if q not in d: 9 yield q 10 d[q * q] = [q] 11 else: 12 for p in d.pop(q): 13 d.setdefault(p + q, []).append(p) 14 ps = list(itertools.islice(primes(), 10000)) 15 print("first 20 primes: " + " ".join(map(str, ps[:20]))) 16 print("primes between 100 and 150: " + " ".join(str(p) for p in ps if 100 <= p <= 150)) 17 print(f"number of primes between 7700 and 8000: {sum(1 for p in ps if 7700 <= p <= 8000)}") 18 print(f"the 10000th prime: {ps[9999]}")