OFFSET
0,3
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..10000
FORMULA
If n is prime, a(n) = 2n, and these points line on the upper straight line in the graph.
If n is not a prime, after n terms we have seen all the numbers from 0 through a(n) and also the doubles of all the primes p in the range a(n)/2 < p < n.
So n = a(n) + pi(n) - pi(a(n)/2). In other words, if n is not a prime then a(n) is the unique solution to a(n) - pi(a(n)/2) = n - pi(n).
This implies that if n is not a prime, a(n) = n*(1 - 1/(2*log(n)) + o(1/log(n))).
These are the points on the lower line, which is not straight but has slope roughly equal to 1.
PROG
(PARI) first(n) = { my(res = vector(n), i = 1); for(x=1, n-1, if(isprime(x), res[x+1] = 2*x, if(setsearch(Set(res), i), i++); res[x+1]=i; i++)); res; } \\ Iain Fox, Nov 18 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Feb 16 2017
STATUS
approved