The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A118777 a(0) = 1; n > 0: a(n) = a(n-1) + d, d = -/+1 if n is prime/nonprime. 2
 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, 11, 12, 13, 14, 15, 14, 15, 16, 17, 16, 17, 16, 17, 18, 19, 18, 19, 20, 21, 22, 23, 22, 23, 24, 25, 26, 27, 26, 27, 26, 27, 28, 29, 30, 31, 30, 31, 32, 33, 32, 33, 32, 33, 34, 35, 36 (list; graph; refs; listen; history; text; internal format)
 OFFSET 0,2 LINKS Antti Karttunen, Table of n, a(n) for n = 0..10000 FORMULA a(n) = n + 1 - 2*primepi(n), n = 0, 1, 2, ..., where primepi(n) = A000720(n). From Antti Karttunen, Aug 21 2016: (Start) a(0) = 1, for n >= 1, a(n) = a(n-1) + (-1)^A010051(n). (from the definition). For all n >= 1, a(n) = 1+A097454(n) = 2+A072731(n). (End) MATHEMATICA (*1*) a=1; s={a}; Do[b=a+If[PrimeQ[n], -1, 1]; AppendTo[s, b]; a=b, {n, 100}]; s (*2*) Table[n + 1 - 2*PrimePi[n], {n, 0, 100}] PROG (Scheme, two versions, the first defined with memoization-macro definec) (definec (A118777 n) (if (zero? n) 1 (+ (A118777 (- n 1)) (expt -1 (A010051 n))))) (define (A118777 n) (+ 1 (- n (* 2 (A000720 n))))) ;; After formula given by the original author. ;; Antti Karttunen, Aug 19 2016 CROSSREFS Cf. A000720, A010051. One more than A097454, two more than A072731. For no apparent reason, the terms a(3)..a(24) are equal to the terms a(0)..a(21) of A276090. Sequence in context: A317754 A317854 A317742 * A073068 A166006 A330935 Adjacent sequences:  A118774 A118775 A118776 * A118778 A118779 A118780 KEYWORD nonn AUTHOR Zak Seidov, May 22 2006 EXTENSIONS Offset and the name corrected by Antti Karttunen, Aug 19 2016 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified June 20 08:30 EDT 2021. Contains 345162 sequences. (Running on oeis4.)