interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

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

14 lines · 532 bytes Raw Blame History
1# Independent reference for "Attractive numbers" (Python 3, standard library only).
2# expected.txt is this program's stdout; omc never produced it.
3def omega(n):
4 k, p = 0, 2
5 while n > 1:
6 while n % p == 0:
7 n //= p
8 k += 1
9 p += 1
10 return k
11att = [n for n in range(1, 121) if omega(n) in (2, 3, 5, 7)]
12print("attractive numbers up to 120 (the count of prime factors, with multiplicity, is prime):")
13for i in range(0, len(att), 20):
14 print("".join(f"{n:4d}" for n in att[i:i + 20]))