%I #21 Nov 01 2021 12:20:38
%S 1,2,1,0,1,0,1,0,1,2,3,2,3,2,3,4,5,4,5,4,5,6,7,6,7,8,9,10,11,10,11,10,
%T 11,12,13,14,15,14,15,16,17,16,17,16,17,18,19,18,19,20,21,22,23,22,23,
%U 24,25,26,27,26,27,26,27,28,29,30,31,30,31,32,33,32,33,32,33,34,35,36
%N a(0) = 1; n > 0: a(n) = a(n-1) + d, d = -/+1 if n is prime/nonprime.
%H Antti Karttunen, <a href="/A118777/b118777.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = n + 1 - 2*primepi(n), n = 0, 1, 2, ..., where primepi(n) = A000720(n).
%F From _Antti Karttunen_, Aug 21 2016: (Start)
%F a(0) = 1, for n >= 1, a(n) = a(n-1) + (-1)^A010051(n). (from the definition).
%F For all n >= 1, a(n) = 1+A097454(n) = 2+A072731(n).
%F (End)
%t Table[n + 1 - 2*PrimePi[n], {n, 0, 100}]
%o (Scheme, two versions, the first defined with memoization-macro definec)
%o (definec (A118777 n) (if (zero? n) 1 (+ (A118777 (- n 1)) (expt -1 (A010051 n)))))
%o (define (A118777 n) (+ 1 (- n (* 2 (A000720 n))))) ;; After formula given by the original author.
%o ;; _Antti Karttunen_, Aug 19 2016
%Y Cf. A000720, A010051.
%Y One more than A097454, two more than A072731.
%Y For no apparent reason, the terms a(3)..a(24) are equal to the terms a(0)..a(21) of A276090.
%K nonn
%O 0,2
%A _Zak Seidov_, May 22 2006
%E Offset and the name corrected by _Antti Karttunen_, Aug 19 2016
|