login
a(n) = nonprime(n) + (-1)^(nonprime(n)).
1

%I #11 Sep 08 2017 03:07:58

%S 1,0,5,7,9,8,11,13,15,14,17,19,21,20,23,25,24,27,26,29,31,33,32,35,34,

%T 37,39,38,41,43,45,44,47,49,48,51,50,53,55,54,57,56,59,61,63,62,65,64,

%U 67,69,68,71,73,75,74,77,76,79,81,80,83,85,84,87,86,89,91,90,93,92,95

%N a(n) = nonprime(n) + (-1)^(nonprime(n)).

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

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

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

%p A141468 := proc(n) option remember ; local a; if n <= 2 then n-1 ; else for a from procname(n-1)+1 do if not isprime(a) then RETURN(a) ; fi; od: fi; end:

%p A164029 := proc(n) A141468(n)+(-1)^A141468(n) ; end: seq(A164029(n), n=1..80) ; # _R. J. Mathar_, Aug 11 2009

%t Join[{1},With[{nn=100},#+(-1)^#&/@Complement[Range[nn],Prime[ Range[ PrimePi[nn]]]]]] (* _Harvey P. Dale_, Jul 24 2011 *)

%Y Cf. A141468.

%K nonn,easy

%O 1,3

%A _Juri-Stepan Gerasimov_, Aug 08 2009

%E a(58) corrected by _R. J. Mathar_, Aug 11 2009