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/perfect-totient-numbers/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 / perfect-totient-numbers / oracle.py` 23 lines ยท 594 bytes Raw Blame History 1 # Independent reference for "Perfect totient numbers" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 def phi(n): 4 r, m, p = n, n, 2 5 while p * p <= m: 6 if m % p == 0: 7 while m % p == 0: 8 m //= p 9 r -= r // p 10 p += 1 11 if m > 1: 12 r -= r // m 13 return r 14 out, n = [], 1 15 while len(out) < 20: 16 n += 1 17 s, v = 0, n 18 while v != 1: 19 v = phi(v) 20 s += v 21 if s == n: 22 out.append(n) 23 print("first 20 perfect totient numbers: " + " ".join(map(str, out)))