login
A330547
a(1)=2; thereafter a(n) = a(n-1) + (-1)^(n+1)*(prime(n)-prime(n-1)) (where prime(k) denotes the k-th prime).
7
2, 1, 3, 1, 5, 3, 7, 5, 9, 3, 5, -1, 3, 1, 5, -1, 5, 3, 9, 5, 7, 1, 5, -1, 7, 3, 5, 1, 3, -1, 13, 9, 15, 13, 23, 21, 27, 21, 25, 19, 25, 23, 33, 31, 35, 33, 45, 33, 37, 35, 39, 33, 35, 25, 31, 25, 31, 29, 35, 31, 33, 23, 37, 33, 35, 31, 45, 39, 49, 47, 51, 45, 53, 47, 53, 49, 55, 47, 51, 43, 53, 51, 61, 59, 65, 61
OFFSET
1,1
COMMENTS
There are several equivalent definitions:
a(n) = (-1)^(n+1)*(prime(n) + 2*(Sum_{i=1..n-1} (-1)^i*prime(n-i)));
a(n) = (-1)^n*(prime(n) - 2*A008347(n)) for n >= 1;
a(n) = A330545(n) if n is odd, a(n) = A330545(n)-1 if n is even;
generating function = P(-x)*(x+1)/(x-1), where P(x) = 2*x + 3*x^2 + 5*x^3 + ... = Sum_{k>=1} prime(k)*x^k is the g.f. for the primes.
Note that the recurrence closely resembles that of A330545, but is slightly simpler. Hans Havermann's graphs of A330545, linked here, also essentially apply to the present sequence.
This sequence ties together A330339, A330545, A008347, and the primes.
Just as A330545 describes the boustrophedon path that generates the "Boustrophedon Primes" in A330339, the present sequence can also be regarded as defining a boustrophedon path with a slightly different rule, as follows. Write the numbers 0, 1, 2, 3, ... in a triangle on a square grid in the boustrophedon manner, ending a row when a prime is reached, and starting the next row in the opposite direction, but displaced by one square in that direction:
-1.0.1.2.3..4..5..6..7..8..9.
-----------------------------
...0 1 2
.....3
.......4 5
.....7 6
.......8 9 10 11
........13 12
...........14 15 16 17
..............19 18
.................20 21 22 23
...
Since all primes>2 are odd, here the odd primes only appear in odd-number4d columns (and in particular there are no primes in column 0).
In fact the primes (other than 2) occur only in odd-numbered columns: primes congruent to 3 mod 4 occur in columns congruent to 1 mod 4, and primes congruent to 1 mod 4 occur in columns congruent to 3 mod 4. See the "Notes" link for proof. - N. J. A. Sloane, Jan 04 2020
It would be nice to know something about the asymptotic growth of this sequence. The usual estimates for the primes do not seem to produce anything useful.
For large n, the graphs of A330545 and A330547 are essentially identical.
Based on the first 10^12 terms, it appears that lim sup |a(n)| is about n^(2/3). This estimate is based on the plots given in A330545 by Sloane, Trump (the first plot), Havermann (the first plot), and Stevenson (all three plots).- N. J. A. Sloane, Jan 21 2020
Conjecture. Let k be an integer and X_k be the set of all n such that (-1)^n*a(n)=2k-1. If a, b are integers and a<>0, then X_k contains infinitely many terms of the arithmetic progression {a*n+b: n integer}. - M. Farrokhi D. G., Nov 12 2023
LINKS
Hans Havermann, Plot of 4*10^8 terms of A330545, sampled every 1000 terms, points joined
Hans Havermann, More detailed view of terms of A330545 from 290 million to 310 million, sampled every 10 terms, points joined.
Frank Stevenson, Plot of first 10^10 terms of A330547, sampled every 10^5 steps. Havermann's plot of 4*10^8 terms appears at the very start of this plot.
Frank Stevenson, Plot of first 10^11 terms of A330547, sampled every 10^6 steps. The preceding plot of 10^10 terms can be seen to the left of the blue line.
Frank Stevenson, Plot of first 10^12 terms of A330547, sampled every 10^7 steps. The preceding plot of 10^11 terms can be seen to the left of the blue line.
MAPLE
f:=n-> (-1)^(n+1)*(ithprime(n)+2*add((-1)^i*ithprime(n-i), i=1..n-1));
[seq(f(n), n=1..400)];
MATHEMATICA
a[1]=2; a[n_]:= a[a]=a[n-1]+ (-1)^(n+1)*(Prime[n]-Prime[n-1]); Table[a[n], {n, 86}] (* James C. McMahon, Dec 18 2023 *)
CROSSREFS
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Dec 19 2019
STATUS
approved