login
A108839
a(1) = 1; a(n) = number of previous terms a(k) such that a(k) + n is prime.
3
1, 1, 0, 2, 2, 2, 1, 0, 3, 4, 5, 4, 4, 2, 7, 5, 6, 5, 5, 1, 4, 5, 3, 6, 6, 7, 8, 6, 7, 7, 6, 5, 5, 6, 11, 16, 13, 9, 9, 11, 12, 13, 7, 4, 6, 11, 10, 12, 8, 7, 8, 12, 12, 15, 17, 14, 12, 11, 15, 16, 15, 14, 11, 13, 16, 21, 22, 18, 12, 11, 16, 17, 14, 12, 12, 12, 20, 17, 10, 8, 14, 14, 16, 13, 21
OFFSET
1,4
EXAMPLE
Among the first 10 terms, a(3) + 11, a(4) + 11, a(5) + 11, a(6) + 11 and a(8) + 11 are primes. So a(11) = 5.
If we add 10 to each of the first 9 terms of the sequence, we get [11,11,10,12,12, 12,11,10,13]. Of these, only the three 11's and the 13 are primes. So a(10) = 4.
MAPLE
A108839 := proc(nmax) local a, nxt, k ; n := 2 ; a := [1] ; while n < nmax do nxt := 0 ; for k from 1 to n-1 do if isprime(op(k, a)+n) then nxt := nxt+1 ; fi ; od ; a := [op(a), nxt] ; n := n+1 ; od ; a ; end: A108839(80) ; # R. J. Mathar, Aug 11 2008
MATHEMATICA
t={1}; Do[AppendTo[t, Length[Select[t+n, PrimeQ]]], {n, 2, 2000}]; t (* T. D. Noe *)
PROG
(PARI) {m=85; v=[1]; for(n=2, m, c=0; for(j=1, length(v), if(isprime(v[j]+n), c++)); v=concat(v, c)); for(j=1, m, print1(v[j], ", "))} - Klaus Brockhaus, Aug 04 2005
(Haskell)
a108839 n = a108839_list !! (n-1)
a108839_list = 1 : f 2 [1] where
f x zs = z : f (x + 1) (z : zs) where
z = toInteger $ sum $ map (a010051 . (+ x)) zs
-- Reinhard Zumkeller, Jul 31 2012
CROSSREFS
Cf. A010051.
Sequence in context: A230536 A306257 A357316 * A114898 A223903 A112159
KEYWORD
nonn
AUTHOR
Leroy Quet, Jul 30 2005
EXTENSIONS
More terms and PARI code from Klaus Brockhaus, Aug 04 2005
Edited by R. J. Mathar, Aug 11 2008
STATUS
approved