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.

A022836 a(n) = c(1)*p(0) + ... + c(n)*p(n-1), where c(i) = 1 if a(i-1) <= p(i-1) and c(i) = -1 if a(i-1) > p(i-1) (with p(0) = 1 and p(i) a prime for i >= 1).

Original entry on oeis.org

1, 3, 6, 1, 8, 19, 6, 23, 4, 27, 56, 25, 62, 21, 64, 17, 70, 11, 72, 5, 76, 3, 82, 165, 76, 173, 72, 175, 68, 177, 64, 191, 60, 197, 58, 207, 56, 213, 50, 217, 44, 223, 42, 233, 40, 237, 38, 249, 26, 253, 24, 257, 18, 259, 8, 265, 2, 271, 542, 265, 546, 263, 556
Offset: 0

Views

Author

Keywords

Comments

Alternate description: a(1) = 1, a(n) = a(n-1) - prime(n) if a(n-1) > prime(n) else a(n) = a(n-1) + prime(n). - Amarnath Murthy and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jun 27 2003

Programs

  • Mathematica
    nxt[{n_,a_}]:=Module[{p=Prime[n]},{n+1,If[a>p,a-p,a+p]}]; NestList[ nxt,{1,1},70][[All,2]] (* Harvey P. Dale, Nov 27 2016 *)

Formula

a(n) = A008348(n) + 1.

Extensions

Name corrected by Sean A. Irvine, May 22 2019