interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / pernicious-numbers / oracle.py

12 lines · 553 bytes Raw Blame History
1# Independent reference for "Pernicious numbers" (Python 3, standard library only).
2# expected.txt is this program's stdout; omc never produced it.
3PRIMES = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
4def pern(n):
5 return bin(n).count("1") in PRIMES
6out, n = [], 0
7while len(out) < 25:
8 n += 1
9 if pern(n):
10 out.append(n)
11print("first 25 pernicious numbers: " + " ".join(map(str, out)))
12print("pernicious numbers from 888888877 to 888888888: " + " ".join(str(n) for n in range(888888877, 888888889) if pern(n)))