OFFSET
1,2
COMMENTS
Numbers n such that floor(n/2) is a positive triangular number. - Bruno Berselli, Sep 15 2014
LINKS
Index entries for linear recurrences with constant coefficients, signature (1,2,-2,-1,1).
FORMULA
a(1) = 1; for n > 1, a(n) = a(n-1)+1 if n is odd, a(n) = a(n-1)+(n-1) if n is even.
G.f.: x*(1+x-x^2+x^3)/((1-x)^3*(1+x)^2).
a(1) = 1; a(n) = a(n-1) + n^(n mod 2) = (1/4)*(n^2 + 2n + 4 + (n mod 2)*(2n-1)). - Rolf Pleisch, Feb 04 2008
a(n) = (2*(n-1)*(n+2) + (2*n-3)*(-1)^n+7)/8. - Bruno Berselli, Mar 31 2011
MATHEMATICA
Table[If[EvenQ[n], 1, n], {n, 0, 56}] // Accumulate (* Jean-François Alcover, Jun 10 2013 *)
Accumulate[Join[{1}, Riffle[Range[1, 85, 2], 1]]] (* or *) LinearRecurrence[ {1, 2, -2, -1, 1}, {1, 2, 3, 6, 7}, 90] (* Harvey P. Dale, Jun 01 2016 *)
PROG
(PARI) {s=0; for(n=1, 57, s=s+if(n%2>0, 1, n-1); print1(s, ", "))}
(PARI) {for(n=1, 57, print1(if(n%2>0, (n^2+3)/4, (n^2+2*n)/4), ", "))}
(Magma) &cat[ [ n^2-n+1, n*(n+1) ]: n in [1..29] ];
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Klaus Brockhaus, May 25 2007
STATUS
approved