OFFSET
1,1
COMMENTS
The sequence starts with the seed [2, 2].
Construction is similar to A347317 except using only prime numbers. Each row ends after counting the highest prime that has occurred in the sequence so far.
When the number of 2's, 3's, 5's, p's is not a prime number, the sequence outputs the prime number closest to but less than the actual count. See example below.
Allowing 0 and 1 in the series is necessary as some primes enter the series before earlier primes. For example, generate the sequence using the example provided below and note on row 47 where 61 appears before 59 in the sequence, approximately the 391st element of the sequence. The effect becomes very clear after generating about 110 rows of data and only gets greater from there, given the overall tendency for increasing gaps between prime numbers.
Related sequences could be generated using different seed strings. Interestingly starting with the seed [3, 3] produces an irregular triangle of similar shape to [2, 2]. This does not seem to occur with 5, 5.
Testing further pairs of primes [p,p] as seeds reveals a subsequence of primes 11,17,29,41,59,71,101,107... that all form a similarly shaped irregular triangle after a trivial amount of 'count up' rows. This can be seen by comparing the row lengths of each pair of primes seed.
It appears that when any of these subsequence values are used as a pair of primes seed that sequence will never include any of the subsequence values. For example, using seed [11,11] the count of 2's skips values 11,17,29,41,59,71,101,107... The same is true if the seed [17,17], or any of the other subsequence values, are used.
LINKS
Anthony B Lara, Table of n, a(n) for n = 1..19538
EXAMPLE
The sequence can be thought of as a row by row counting of prime occurrences with each column relating to a specific prime number, given the first two seed rows of 2 and 2.
As an irregular triangle this begins:
Row1: 2 (seed)
Row2: 2 (seed)
Row3: 2
Row4: 3 1
Row5: 3 2
Row6: 3 3
Row7: 3 5 1
Row8: 3 5 2
Row9: 5 5 3
Note in Row8 how the number of 3's that have occurred so far is actually 6, but the rules of the sequence dictate outputting the nearest prime less than the count which is 5.
PROG
(Python)
from itertools import islice
from collections import Counter
from sympy import isprime, nextprime, prevprime
def agen(verbose=False): # generator of terms; verbose=True prints rows
seed, bigp = [2, 2], 2
c = Counter(seed)
yield from seed
if verbose: [print(k, end=", \n") for k in seed]
while True:
p = 2
while p <= bigp:
cp = c[p]
if cp > 2 and not isprime(cp): cp = prevprime(cp)
if cp > bigp: bigp = cp
yield cp
if verbose: print(cp, end=", ")
c[cp] += 1
p = nextprime(p)
if verbose: print()
print(list(islice(agen(), 94))) # Michael S. Branicky, Sep 10 2024
CROSSREFS
KEYWORD
nonn,base,tabf
AUTHOR
Anthony B Lara, Sep 08 2024
STATUS
approved