login
prime(n) -(-1)^(n-th nonprime).
1

%I #8 Jan 24 2021 13:48:11

%S 1,4,4,6,10,14,16,18,22,30,30,36,40,44,46,52,60,60,68,70,72,78,84,88,

%T 98,100,102,108,108,112,126,132,136,138,150,150,158,162,166,174,178,

%U 182,190,192,196,200,210,224,226,228,234,238,240,250,258,262,270,270,276,282,282

%N prime(n) -(-1)^(n-th nonprime).

%H G. C. Greubel, <a href="/A163976/b163976.txt">Table of n, a(n) for n = 1..5000</a>

%F a(n) = A000040(n) -(-1)^A141468(n) .

%e a(1) = 2-(-1)^0 = 1. a(2) = 3-(-1)^1=4.

%t nonPrime[n_Integer] := FixedPoint[n + PrimePi@# &, n + PrimePi@n];

%t Table[Prime[n + 1] - (-1)^(nonPrime[n]), {n, 0, 50}] (* _G. C. Greubel_, Aug 24 2017 *)

%t Module[{nn=200,np,pr,len},np=Select[Range[0,nn],!PrimeQ[#]&];len= Length[ np];#[[1]]-(-1)^#[[2]]&/@Thread[{Prime[Range[len]],np}]] (* _Harvey P. Dale_, Jan 24 2021 *)

%Y Cf. A000040, A141468.

%K nonn

%O 1,2

%A _Juri-Stepan Gerasimov_, Aug 07 2009

%E Entries checked by _R. J. Mathar_, Oct 10 2009