来自在线整数百科全书的问候语!http://oeis.org/ Search: id:a033539 Showing 1-1 of 1 %I A033539 %S A033539 1,1,1,4,10,25,61,148,358,865,2089,5044,12178,29401,70981,171364, %T A033539 413710,998785,2411281,5821348,14053978,33929305,81912589,197754484, %U A033539 477421558,1152597601,2782616761,6717831124,16218279010,39154389145 %N A033539 a(0)=1, a(1)=1, a(2)=1, a(n) = 2*a(n-1) + a(n-2) + 1. %C A033539 a(n) or a(n+1) gives the number of times certain simple recursive procedures are called to effect a reversal of a sequence of n elements (including both the top-level call and any subsequent recursive calls). 参见示例和程序线。%%A033539 T.D.NOE,n,a(n)n=0…300的表%H A033539 A. Karttunen,更多信息%H A033539常系数线性递归的索引项,签名(3,-1,-1).0%F A033539 A(n)=(3/4)*(1 +SqRT(2))^(n-1)+3/4 *(1-qRT(2))^(n-1)-1/2+3*0 ^ n,n=0。9月10日,2009 J% LF,AF 3A3539 G.F.:(1 - 2×X-X ^ 2 +3×X^ 3)/((1-x)*(1-2×X-X ^ 2))。α-JuMu奥利弗LaFuntz,SEP 09(2009)F A033539 A(n)=3*A(N-1)-A(N-2)-A(n-3),A(0)=1,A(1)=1,A(2)=1,A(3)=4。11月20日,2011岁的F A033539 A(n)=(3×A00 1333(N-1)- 1)/ 2。-A.R.J.MathARGy,MAR 04 2013 0%F A033539 A(n)=-1/2(3/4)*(1 +SqRT(2))^ n-(3/4)*SqRT(2)*(1-SqRT(2))^ n-(3/4)*(1-qRT(2))^ n+(3/4)*(3/4 +qRT(α))^ n*qRT(α)为n>=α。-亚历山大R PoVoToSkyz,MAR 05 2013πF A033539 E.G.F.:3 +(1/2)*EXP(x)*(-1 -3×COSH(Sqt(2)*x)+ 3×SqRT(2)*Snh(Sqt(2)*x))。- _Stefano Spezia_, Oct 13 2019 %e A033539 See the Python, Erlang (myrev), Pari (rev) and Forth definitions (REV3) given at Program section. %e A033539 Pari, Python and Erlang functions are called a(n+1) times for the list of length n, while Forth word REV3 is called a(n) times if there are n elements in the parameter stack. %p A033539 seq(coeff(series((1 -2*x -x^2 +3*x^3)/((1-x)*(1-2*x-x^2)), x, n+1), x, n), n = 0..30); # _G. C. Greubel_, Oct 13 2019 %t A033539 Join[{1},RecurrenceTable[{a[0]==a[1]==1,a[n]==2a[n-1]+a[n-2]+1},a,{n,30}]] (* or *) LinearRecurrence[{3,-1,-1},{1,1,1,4},30] (* _Harvey P. Dale_, Nov 20 2011 *) %t A033539 Table[If[n==0, 1, (3*LucasL[n-1, 2] -2)/4], {n, 0, 30}] (* _G. C. Greubel_, Oct 13 2019 *) %o A033539 (Haskell) %o A033539 a033539 n = a033539_list !! n %o A033539 a033539_list = %o A033539 1 : 1 : 1 : (map (+ 1) $ zipWith (+) (tail a033539_list) %o A033539 (map (2 *) $ drop 2 a033539_list)) %o A033539 -- _Reinhard Zumkeller_, Aug 14 2011 %o A033539 (PARI) %o A033539 /* needs version >= 2.5 */ %o A033539 /* function demonstrating the reversal of the lists and counting the function calls: */ %o A033539 rev( L )={ cnt++; if( #L>1, my(x,y); x=L[#L]; listpop(L); L=rev(L); y=L[#L]; listpop(L); L=rev(L); listput(L,x); L=rev(L); listput(L,y)); L } %o A033539 for(n=0,50,cnt=0;print(n": rev(",L=List(vector(n,i,i)),")=",rev(L),", cnt="cnt)) \\ _Antti Karttunen_, Mar 05 2013, partially based on previous PARI code from _Michael Somos_, 1999. Edited by _M. F. Hasler_, Mar 05 2013 %o A033539 (Python) %o A033539 # function, demonstrating the reversal of the lists: %o A033539 def myrev(lista): %o A033539 '''Reverses a list, in cumbersome way.''' %o A033539 if(len(lista) < 2): return(lista) %o A033539 else: %o A033539 tr = myrev(lista[1:]) %o A033539 return([tr[0]]+myrev([lista[0]]+myrev(tr[1:]))) %o A033539 (Erlang) %o A033539 # definition, demonstrating the reversal of the lists: %o A033539 myrev([]) -> []; %o A033539 myrev([A]) -> [A]; %o A033539 myrev([X|Y]) -> %o A033539 [A|B] = myrev(Y), %o A033539 [A|myrev([X|myrev(B)])]. %o A033539 (Forth) %o A033539 # definition, demonstrating how to turn a parameter stack upside down: %o A033539 : REV3 DEPTH 0= IF ELSE DEPTH 1 = IF ELSE DEPTH 2 = IF SWAP ELSE >R RECURSE R> SWAP >R >R RECURSE R> RECURSE R> THEN THEN THEN ; %o A033539 -- _Antti Karttunen_, Mar 04 2013 %o A033539 (PARI) concat([1], vector(30, n, (3*sum(k=0,(n-1)\2, binomial(n-1,2*k) * 2^k) - 1)/2 )) \\ _G. C. Greubel_, Oct 13 2019 %o A033539 (MAGMA) I:=[1,1,4]; [1] cat [n le 3 select I[n] else 3*Self(n-1) - Self(n-2) - Self(n-3): n in [1..30]]; // _G. C. Greubel_, Oct 13 2019 %o A033539 (Sage) [1]+[(3*lucas_number2(n-1,2,-1) -2)/4 for n in (1..30)] # _G. C. Greubel_, Oct 13 2019 %o A033539 (GAP) Concatenation([1], List([1..30], n-> (3*Lucas(2,-1,n-1)[2] -2)/4 )); # _G. C. Greubel_, Oct 13 2019 %Y A033539 Cf. A002203, A033538. %K A033539 nonn,easy,nice %O A033539 0,4 %A A033539 _Antti Karttunen_ # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE