Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #38 Sep 08 2022 08:46:21
%S 0,1,2,2,3,4,4,5,6,6,7,7,7,8,9,9,9,10,10,11,12,12,13,13,13,14,14,14,
%T 15,16,16,16,17,17,18,19,19,19,20,20,21,21,21,22,22,22,22,23,23,24,25,
%U 25,26,27,27,28,28,28,28,28,28,28,29,29,30,30,30,31
%N a(0) = 0, a(n) = a(n-1) + 1 if 2*n + 3 is prime, otherwise a(n) = a(n-1).
%C It appears that A000040(a(n)) ~ 2*n as n tends to infinity. (See Mar 12 2012 note from _Vladimir Shevelev_ in A060308.)
%H Carlos Fernandez Rivero, <a href="/A308754/b308754.txt">Table of n, a(n) for n = 0..10000</a>
%H Carlos Fernandez Rivero, <a href="/A308754/a308754.jpg">Plots of a(n) for n = 0..200 and n = 0..10000</a>
%F a(n) = a(n-1) + A101264(n+1), n > 0.
%F a(n) = A000720(2 * (n+2)) - 2.
%F a(n) = A099801(n+1) - 2.
%F a(n) = n - A210469(n+2).
%F A000040(a(n) + 2) = A060265(n+2).
%F A000040(a(n) + 2) = A060308(n+2).
%F A000040(a(n) + 2) = A085090(n+2), if 2*n + 3 is prime, otherwise 0.
%e a(0) = 0 (by definition).
%e a(1) = 1 = a(0) + 1, because 2*1 + 3 is prime;
%e a(2) = 2 = a(1) + 1, because 2*2 + 3 is prime;
%e a(3) = 2 = a(2), because 2*3 + 3 is not prime;
%e a(4) = 3 = a(3) + 1, because 2*4 + 3 is prime.
%t a[0] = 0; a[n_] := a[n] = a[n - 1] + Boole@PrimeQ[2 n + 3]; Array[a, 100, 0] (* _Amiram Eldar_, Jul 06 2019 *)
%o (BASIC)
%o ' p(n) contains the prime sequence except for 2. p(0)=3
%o ' output in the a(n) sequence for 0 <= n <= maxterm
%o ip = -1
%o For n = 0 To maxterm
%o If (2 * n + 3) = p(ip+1) Then
%o ip = ip + 1
%o End If
%o a(n) = ip
%o Next n
%o (Magma) [#PrimesUpTo(2*n + 4) - 2: n in [0..80] ]; // _Vincenzo Librandi_, Aug 01 2019
%Y Cf. A000040, A000720, A060265, A060308, A085090, A099801, A101264.
%K nonn,easy
%O 0,3
%A _Carlos Fernandez Rivero_, Jun 22 2019