import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfi import RealIntervalField
from sage.arith.misc import prime_range
def prime_indicator(b, digits=100):
b = ZZ(b)
if b < 2:
raise ValueError('b must be an integer >= 2')
M = 1
while (b-1)*b**M <= 10**(digits+20):
M += 1
S = sum((QQ(1)/b**p for p in prime_range(M+1)), QQ(0))
F = RealIntervalField(max(512, numberdb.bits(digits+40)))
return F(S, S+QQ(1)/((b-1)*b**M))
# The initial finite selection; prime_indicator(b) also accepts other b>=2.
for b in range(2, 17):
print(b, prime_indicator(b))
The generator sums exact rational terms for primes at most $M$, using a sieve. It selects $M$ by the exact inequality $(b-1)b^M>10^{d+20}$ for requested decimal precision $d$, and encloses the infinite sum between $S_M$ and $S_M+b^{-M}/(b-1)$. The two rational endpoints are converted outward with MPFI, using $512$ bits for the default $d=100$. No finite prefix is treated as the exact infinite value.
A separate implementation uses trial division, the prime-counting identity and its independently bounded tail. All fifteen serialized intervals contain those narrower exact brackets; their first $23$ radix digits agree with the prime-position rule. The binary member agrees with the first $150$ decimal source digits. Known prime-count and finite-identity controls and deliberately altered values, digit positions and source digits check the checker. The displayed Sage program is also checked on every selected radix. Source hashes, code, exact brackets and measured widths are attached. These computations support the stated enclosures and do not assert transcendence or normality.