cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A118777 a(0) = 1; n > 0: a(n) = a(n-1) + d, d = +-1 if n is prime/nonprime.

Original entry on oeis.org

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
Offset: 0

Views

Author

Zak Seidov, May 22 2006

Keywords

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.

Programs

  • Mathematica
     Table[n + 1 - 2*PrimePi[n], {n, 0, 100}]
  • Scheme
    ;; With memoization-macro definec.
    (definec (A118777 n) (if (zero? n) 1 (+ (A118777 (- n 1)) (expt -1 (A010051 n)))))
    ;; Antti Karttunen, Aug 19 2016
    
  • Scheme
    (define (A118777 n) (+ 1 (- n (* 2 (A000720 n))))) ;; After formula given by the original author.
    ;; Antti Karttunen, Aug 19 2016

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)

Extensions

Offset and the name corrected by Antti Karttunen, Aug 19 2016