

A336891


Sequence following Van Eck's sequence unless a prime which was previously encountered is found, in which case, a(n+1) = n  m, where m is the largest possible value such that a(m) is also prime.


0



0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 2, 1, 7, 0, 5, 2, 1, 5, 2, 1, 3, 0, 8, 0, 2, 4, 0, 3, 3, 1, 10, 0, 5, 4, 8, 12, 0, 5, 5, 1, 10, 10, 1, 3, 5, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,5


COMMENTS

Van Eck's sequence (A181391) is an integer sequence defined as follows; Let a(0) = 0. For, n >= 0, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = n  m, otherwise a(n+1) = 0. This sequence modifies the Van Eck sequence, adding an additional condition in that if a(n) is prime, set a(n+1) = n  m, where m is the largest possible value such that a(m) is also prime.


LINKS

Table of n, a(n) for n=1..86.


EXAMPLE

Start with a(1) = 0.
0 has not occurred before, so the rule says a(2) = 0.
Now 0 HAS occurred before, at a(1), 0 is not prime, so a(3) = 1, which is the number of places before a(2) where 0 occurs.
1 has not occurred before, so a(4) = 0.
0 occurred most recently at term a(2) and is not prime, so a(5) = 2.
2 has not occurred before, so a(6) = 0.
0 occurred most recently at term a(4) and is not prime, so a(7) = 2.
2 occurred most recently at term a(5) and 2 IS prime, so a(8) = 2 which is the number of places back where the previous prime occurred.
.. and so on!


PROG

(PARI) lista(nn) = {my(t, v=vector(nn)); for(n=2, nn1, if(vecsearch(vecsort(v[1..n1]), v[n]), t=1; if(isprime(v[n]), while(!isprime(v[nt]), t++), while(v[nt]!=v[n], t++)); v[n+1]=t)); v; } \\ Jinyuan Wang, Aug 20 2020


CROSSREFS

Cf. A181391 (Van Eck's sequence).
Sequence in context: A112803 A124242 A112274 * A181391 A333359 A341846
Adjacent sequences: A336888 A336889 A336890 * A336892 A336893 A336894


KEYWORD

nonn


AUTHOR

Philip Mizzi, Aug 07 2020


EXTENSIONS

More terms from Jinyuan Wang, Aug 07 2020


STATUS

approved



