login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
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
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
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
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
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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 07:48 EDT 2024. Contains 371235 sequences. (Running on oeis4.)