login
A197124
Extract positive numbers from the infinite string of prime numbers 235711131719..., constructing the smallest numbers which have not appeared in an earlier extraction.
3
2, 3, 5, 7, 1, 11, 31, 71, 9, 23, 29, 313, 74, 14, 34, 75, 35, 96, 16, 77, 17, 37, 98, 38, 99, 710, 110, 310, 7109, 113, 12, 713, 1137, 13, 91, 4, 915, 115, 716, 316, 717, 317, 918, 119, 1193, 19, 719, 92, 112, 232, 27, 22, 923, 32, 39, 24, 125, 1257, 26
OFFSET
1,1
COMMENTS
The infinite stream of prime digits is basically chopped into slices such that each of the digits is used exactly once and the outcoming stream does not contain duplicates.
EXAMPLE
The initial digits 2, 3, 5, 7 and 1 are all extracted in the order of occurrence. The next 1 is rejected because it appeared earlier, and united with the (overall) third 1 to extract 11. The next 3 (from 13) appeared already earlier and is combined with the following 1 (from the 17) to created 31.
MATHEMATICA
nn=100; digs = Flatten[Table[IntegerDigits[Prime[n]], {n, nn}]]; numList = {}; While[digs != {}, num = 0; While[num = num*10 + digs[[1]]; digs = Rest[digs]; newNum = ! MemberQ[numList, num]; (num == 0 || ! newNum) && digs != {}]; If[newNum, AppendTo[numList, num]]]; numList (* T. D. Noe, Oct 31 2011 *)
PROG
(Python)
from sympy import nextprime
from itertools import islice
def diggen():
p = 2
while True:
yield from list(map(int, str(p)))
p = nextprime(p)
def agen(): # generator of terms
g = diggen()
aset, nextd = set(), next(g)
while True:
an, nextd = nextd, next(g)
while an in aset or nextd == 0:
an, nextd = int(str(an) + str(nextd)), next(g)
yield an
aset.add(an)
print(list(islice(agen(), 80))) # Michael S. Branicky, Mar 31 2022
CROSSREFS
Sequence in context: A130138 A171855 A130136 * A032759 A142711 A357096
KEYWORD
nonn,base
AUTHOR
Yves Debeuret, Oct 10 2011
STATUS
approved