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/kaprekar-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 / kaprekar-numbers / oracle.py` 14 lines ยท 554 bytes Raw Blame History 1 # Independent reference for "Kaprekar numbers" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 def kaprekar(n): 4 if n == 1: 5 return True 6 s = str(n * n) 7 for i in range(1, len(s)): 8 a, b = int(s[:i]), int(s[i:]) 9 if b > 0 and a + b == n: 10 return True 11 return False 12 ks = [n for n in range(1, 10**6) if kaprekar(n)] 13 print("Kaprekar numbers below 10000: " + " ".join(str(k) for k in ks if k < 10000)) 14 print(f"count of Kaprekar numbers below `1000000`: {len(ks)}")