interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / prime-decomposition / oracle.py

13 lines · 444 bytes Raw Blame History
1# Independent reference for "Prime decomposition" (Python 3, standard library only).
2# expected.txt is this program's stdout; omc never produced it.
3def f(n):
4 out, d = [], 2
5 while d * d <= n:
6 while n % d == 0:
7 out.append(d); n //= d
8 d += 1
9 if n > 1:
10 out.append(n)
11 return out
12for n in [12, 360, 97, 1001, 2147483647, 600851475143, 2**64 - 1]:
13 print(f"{n} = " + " x ".join(map(str, f(n))))