login
A217602
Let a(1) = 1. If n and a(n-1) have the same parity, a(n) = n + a(n-1), otherwise a(n) = abs(n - a(n-1)).
1
1, 1, 4, 8, 3, 3, 10, 18, 9, 1, 12, 24, 11, 3, 18, 34, 17, 1, 20, 40, 19, 3, 26, 50, 25, 1, 28, 56, 27, 3, 34, 66, 33, 1, 36, 72, 35, 3, 42, 82, 41, 1, 44, 88, 43, 3, 50, 98, 49, 1, 52, 104, 51, 3, 58, 114, 57, 1, 60, 120, 59, 3, 66, 130, 65, 1, 68, 136, 67
OFFSET
1,3
COMMENTS
a(4n+1) and a(4n+2) are odd, while a(4n+3) and a(4n) are even. This allows recurrence relations to be defined for this sequence for each congruence class mod 4. - Charles R Greathouse IV, Oct 09 2012
LINKS
FORMULA
G.f.: -x*(2*x^10+3*x^8-8*x^7-2*x^6-4*x^5+2*x^4-4*x^3-4*x^2-1)/((x-1)^2*(x+1)*(x^2+1)^2*(x^4+1)). - Colin Barker, Oct 11 2012
EXAMPLE
For n = 4 ,a(n-1) = 4 , the parity are the same therefore a(4)= 4+4 = 8.
For n = 5 ,a(n-1) = 8 , the parity are opposite therefore a(5) = |5-8| = 3.
MATHEMATICA
last = 1; Join[{last}, Table[If[Mod[n - last, 2] == 0, s = n + last, s = Abs[n - last]]; last = s, {n, 2, 100}]] (* T. D. Noe, Oct 09 2012 *)
CoefficientList[Series[-(2*x^10 + 3*x^8 - 8*x^7 - 2*x^6 - 4*x^5 + 2*x^4 - 4*x^3 - 4*x^2 - 1)/((x - 1)^2*(x + 1)*(x^2 + 1)^2*(x^4 + 1)), {x, 0, 100}], x] (* Vincenzo Librandi, Dec 28 2012 *)
PROG
(PARI) x='x+O('x^80); Vec(-x*(2*x^10+3*x^8-8*x^7-2*x^6-4*x^5+2*x^4-4*x^3 -4*x^2-1)/((x-1)^2*(x+1)*(x^2+1)^2*(x^4+1))) \\ G. C. Greubel, Aug 31 2018
(Magma) m:=80; R<x>:=PowerSeriesRing(Integers(), m); Coefficients(R!(-x*(2*x^10+3*x^8-8*x^7-2*x^6-4*x^5+2*x^4-4*x^3 -4*x^2-1)/((x-1)^2*(x+ 1)*(x^2+1)^2*(x^4+1)))); // G. C. Greubel, Aug 31 2018
CROSSREFS
Sequence in context: A019698 A132797 A309217 * A300690 A193077 A271871
KEYWORD
nonn,easy
AUTHOR
Kival Ngaokrajang, Oct 07 2012
STATUS
approved