[go: up one dir, main page]

login
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

%I #33 Sep 08 2022 08:46:04

%S 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,

%T 56,27,3,34,66,33,1,36,72,35,3,42,82,41,1,44,88,43,3,50,98,49,1,52,

%U 104,51,3,58,114,57,1,60,120,59,3,66,130,65,1,68,136,67

%N 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)).

%C 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

%H Vincenzo Librandi, <a href="/A217602/b217602.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_11">Index entries for linear recurrences with constant coefficients</a>, signature (1,-1,1,0,0,0,0,1,-1,1,-1).

%F 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

%e For n = 4 ,a(n-1) = 4 , the parity are the same therefore a(4)= 4+4 = 8.

%e For n = 5 ,a(n-1) = 8 , the parity are opposite therefore a(5) = |5-8| = 3.

%t 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 *)

%t 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 *)

%o (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

%o (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

%K nonn,easy

%O 1,3

%A _Kival Ngaokrajang_, Oct 07 2012