OFFSET
1,2
LINKS
Robert G. Wilson v, Table of n, a(n) for n = 1..1029 (first 422 terms from Manfred Scheucher)
Manfred Scheucher, Sage Script (Note: should also run in pure python with a few modifications)
EXAMPLE
Find the first occurrence of prime 2 in the digits of Pi (only 25 digits in this illustration):
3141592653589793238462643..., and replace it with a space:
314159 653589793238462643... Repeat the process with 3:
14159 653589793238462643... Then 5:
141 9 653589793238462643... Then 7:
141 9 653589 93238462643... Then 11, 13, 17, etc., until the first occurrence of every prime is eliminated from the digits of Pi.
1 9 6 5 93 84626 ... Then consolidate gaps between the remaining digits into a single comma:
1,9,6,5,93,84626,... to produce the first terms in the prime sieve of Pi.
PROG
(Python)
def arccot(x, unity):
....sum = xpower = unity // x
....n = 3
....sign = -1
....while 1:
........xpower = xpower // (x*x)
........term = xpower // n
........if not term:
............break
........sum += sign * term
........sign = -sign
........n += 2
....return sum
def pi(digits):
....unity = 10**(digits + 10)
....pi = 4 * (4*arccot(5, unity) - arccot(239, unity))
....return pi // 10**10
def primes(n):
....""" Returns a list of primes < n """
....sieve = [True] * n
....for i in range(3, int(n**0.5)+1, 2):
........if sieve[i]:
............sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1)
....return [2] + [i for i in range(3, n, 2) if sieve[i]]
a = pi(370)
b = primes(100000000)
y = str(a)
for x in b:
....if str(x) in y:
........y = y.replace(str(x), " ", 1)#replace first occurrence only
........
while " " in y:
....y = y.replace(" ", " ")#replace long chains of spaces with a single space
z = y.split(" ")#split terms into a list
z = filter(None, z)#remove null terms
f = map(int, z)#convert to integers
print(f[0:-1])
# David Consiglio, Jr., Jan 03 2015
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Gil Broussard, Aug 01 2014
EXTENSIONS
a(14) corrected by Manfred Scheucher, May 25 2015
STATUS
approved