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.
%I A278603 #42 Jan 09 2021 02:46:53 %S A278603 0,1,2,1,2,3,2,1,2,3,4,5,4,3,4,5,6,7,6,5,6,7,8,9,8,7,6,5,4,3,4,5,4,3, %T A278603 2,1,0,-1,0,1,2,3,2,1,2,3,4,5,4,3,2,1,0,-1,0,1,2,3,4,5,4,3,4,5,6,7,8, %U A278603 9,8,7,6,5,6,7,6,5,4,3,2,1,2,3,4,5,4,3 %N A278603 A prime mountain: peaks and valleys beyond the origin correspond to prime abscissa (see Comments for precise definition). %C A278603 We start with a(0)=0 and a(1)=1, and then the sequence is extended according to these rules: %C A278603 (1) |a(n+1) - a(n)| = 1 for any n>1, %C A278603 (2) a(n+1) = a(n-1) iff n is prime. %C A278603 Is this sequence ultimately positive or ultimately negative or will it change sign indefinitely? %C A278603 From _Ryan Bresler_, Jan 04 2021: (Start) %C A278603 This sequence will contain every integer on "at least one side" of the origin, i.e., it will not have a finite range. %C A278603 Suppose this sequence has both a finite minimum, R1, and a finite maximum, R2. Since prime gaps become arbitrarily large, we will eventually reach a prime gap g, such that g > R2 - R1. We can see that this prime gap will cause at least one term of this sequence to be outside the interval [R1, R2]. This contradiction shows that all integers on at least one side of the origin will be terms of the sequence. %C A278603 (End) %H A278603 Rémy Sigrist, <a href="/A278603/b278603.txt">Table of n, a(n) for n = 0..10000</a> %F A278603 a(prime(n)) = prime(1) + Sum_{k=1..n-1} A001223(k)*(-1)^k for any n > 0. %F A278603 a(n+1) = A065358(n) + 1 for any n >= 0. - _Rémy Sigrist_, Feb 22 2018 %e A278603 a(2) is either a(1) + 1 = 2 or a(1) - 1 = 0. %e A278603 As 1 is not prime, a(2) = a(1+1) != a(1-1) = 0. %e A278603 Hence, a(2) = 2. %e A278603 As 2 is prime, a(3) = a(2+1) = a(2-1) = a(1) = 1. %e A278603 As 3 is prime, a(4) = a(3+1) = a(3-1) = a(2) = 2. %e A278603 a(5) is either a(4)+1 = 3 or a(4)-1 = 1. %e A278603 As 4 is not prime, a(5) = a(4+1) != a(4-1) = 1. %e A278603 Hence, a(5) = 3. %e A278603 The first terms can be visualized here (peaks correspond to odd-indexed primes, and valleys to even-indexed primes): %e A278603 . /\ ... %e A278603 . / \/ %e A278603 . /\ / %e A278603 . / \/ %e A278603 . /\ / %e A278603 . /\/ \/ %e A278603 . / %e A278603 . 2 5 11 17 %e A278603 . 0 3 7 13 19 %o A278603 (PARI) y=0; slope=+1; for (x=0, 85, print1 (y ", "); if (isprime(x), slope = -slope); y+=slope) %Y A278603 Cf. A001223, A065358. %K A278603 sign %O A278603 0,3 %A A278603 _Rémy Sigrist_, Nov 23 2016