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/mobius-function/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 / mobius-function / oracle.py` 17 lines · 584 bytes Raw Blame History 1 # Independent reference for "Möbius function" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 def mu(n): 4 f, d, m = 0, 2, n 5 while d * d <= m: 6 if m % d == 0: 7 m //= d 8 if m % d == 0: 9 return 0 10 f += 1 11 d += 1 12 if m > 1: 13 f += 1 14 return -1 if f % 2 else 1 15 print("first 199 terms of the Moebius sequence (the first cell, n = 0, is blank):") 16 for r in range(10): 17 print("".join(" " if n == 0 else f"{mu(n):3d}" for n in range(20 * r, 20 * r + 20)))