back to table · edit · history · where entries came from · files · download
681 bytes, as of the version from 2026-12-01 12:19 (current). Recorded here, not run.
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))