OFFSET
1,2
COMMENTS
If we did not skip earlier occurring integers when counting, we would instead have Cald's sequence (A006509).
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
EXAMPLE
The first 5 terms of the sequence can be plotted on the number line as:
1,2,3,*,*,6,*,*,*,*,11,*,*,*,*,*.
a(5) is 2. Counting p(5) = 11 down from 2 gets a negative integer. So we instead count up 11 positions, skipping the 3, 6 and 11 as we count, to arrive at 16 (which is at the rightmost * of the number line above).
Here is the calculation of the first 6 terms in more detail:
integers i : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
i at n = ... : 1 5 2 . . 3 . . . .. .4 .. .. .. .. .6 ...
prime p used : - 7 2 . . 3 . . . .. .5 .. .. .. .. 11 ...
PROG
(Haskell)
import Data.Set (singleton, member, insert)
a110080 n = a110080_list !! (n-1)
a110080_list = 1 : f 1 a000040_list (singleton 1) where
f x (p:ps) m = y : f y ps (insert y m) where
y = g x p
g 0 _ = h x p
g u 0 = u
g u v = g (u - 1) (if member (u - 1) m then v else v - 1)
h u 0 = u
h u v = h (u + 1) (if member (u + 1) m then v else v - 1)
-- Reinhard Zumkeller, Sep 02 2014
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Leroy Quet, Oct 12 2005
EXTENSIONS
More terms from Klaus Brockhaus and Hans Havermann, Oct 17 2005
STATUS
approved