login
a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th nonprime.
11

%I #22 Oct 17 2015 08:52:15

%S 1,1,2,2,3,3,4,4,5,6,5,7,6,8,9,10,7,11,8,12,13,14,9,15,16,17,18,19,10,

%T 20,11,21,22,23,24,25,12,26,27,28,13,29,14,30,31,32,15,33,34,35,36,37,

%U 16,38,39,40,41,42,17,43,18,44,45,46,47,48

%N a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th nonprime.

%C Each n occurs at two positions, the distances between them are: 1, 1, 1, 1, 2, 3, 5, 5, 8, 13, 13, 17, 20, 21, 23, 28, 33, 34, 39, 41, 41, ... - _Zak Seidov_, Mar 06 2011

%H Reinhard Zumkeller, <a href="/A026233/b026233.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A049084(n) + A066246(n) + A000007(A010051(n)). - _Reinhard Zumkeller_, Feb 12 2014

%F a(n) = A049084(n) + A239968(n). - _Reinhard Zumkeller_, Mar 30 2014

%t m=100;pr=Prime[Range[m]];npr=Select[Range[m],!PrimeQ[#]&];

%t a[n_]:=If[PrimeQ[n],PrimePi[n],Position[npr,n][[1,1]]]; Table[a[n],{n,m}] (* Zak Seidov Mar 05 2011 *) s=Range[500];Do[s=Insert[s,n,Prime[n]],{n,100}];s (* _Zak Seidov_, Mar 05 2011 *)

%o (Haskell)

%o a026233 n = a049084 n + a239968 n

%o -- _Reinhard Zumkeller_, Mar 30 2014, Feb 12 2014

%o (PARI) first(n)=my(p,c); vector(n,k,if(isprime(k),p++,c++)) \\ _Charles R Greathouse IV_, Sep 02 2015

%Y Cf. A026238.

%K nonn

%O 1,3

%A _Clark Kimberling_