OFFSET
0,1
COMMENTS
First 20 terms are primes with periodic second order differences (4, 4, 2, 2, 4, 4, 2, 2, 4, 4, 2, 2, 4, 4, 2, 2, 4, 4) which continue onwards.
The number of prime and nonprime terms is equal at a(1809): 905, a(1811): 906, a(1817): 909, a(1819): 910, a(1821): 911, a(1823): 912, a(1825): 913, a(1827): 914, a(1829): 915, and at a(1837): 919 (i.e. 919 prime and 919 nonprime terms among the total 1838 terms).
Single longer blocks containing only primes include 20, 14, 12, and 11 terms (in range n=0...10^8) while the longest block of nonprime terms in this range has length 78.
LINKS
Colin Barker, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-4,4,-3,1).
FORMULA
G.f.: (-149x^4 + 296x^3 - 300x^2 + 296x - 149)/((x-1)^3*(x^2+1)).
a(n) = 2*floor(3*n*(n + 1)/4) + 149.
a(n) = A007310(n(n + 1)/2 + 50).
a(n) = (3*(n^2+n+99)+(-1)^binomial(n+1,2))/2. (Suggested by Michel Marcus)
a(n) - a(-n-1) = 0. - Altug Alkan, Feb 04 2016
a(n) = ((1/4+i/4)*((297-297*i)-i*(-i)^n+i^n)+(3*n)/2+(3*n^2)/2) where i is the imaginary unit. - Colin Barker, Feb 09 2016
MATHEMATICA
Table[2*Floor[3*n*(n+1)/4] + 149, {n, 0, 10000}] (* Efficient. *)
Table[(3*(n^2+n+99)+Cos[Pi*n/2]-Sin[Pi*n/2])/2, {n, 0, 1000}](* or *)
LinearRecurrence[{3, -4, 4, -3, 1}, {149, 151, 157, 167, 179}, 1000]
CoefficientList[Series[(-149 x^4 + 296 x^3 - 300 x^2 + 296 x - 149) / ((x - 1)^3 (x^2 + 1)), {x, 0, 50}], x] (* Vincenzo Librandi, Feb 05 2016 *)
PROG
(PARI) Vec((-149*x^4 + 296*x^3 - 300*x^2 + 296*x - 149)/((x-1)^3*(x^2+1)) + O(x^60)) \\ Michel Marcus, Feb 04 2016
(PARI) a(n) = ((1/4+I/4)*((297-297*I)-I*(-I)^n+I^n)+(3*n)/2+(3*n^2)/2) \\ Colin Barker, Feb 09 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Mikk Heidemaa, Feb 04 2016
STATUS
approved