%I #77 Dec 24 2023 09:37:15
%S 1,0,1,2,1,4,1,6,1,8,1,10,1,12,1,14,1,16,1,18,1,20,1,22,1,24,1,26,1,
%T 28,1,30,1,32,1,34,1,36,1,38,1,40,1,42,1,44,1,46,1,48,1,50,1,52,1,54,
%U 1,56,1,58,1,60,1,62,1,64,1,66,1,68,1,70,1,72,1,74,1,76,1,78,1,80,1,82,1,84
%N Even numbers sandwiched between 1's.
%C Interleaving of A000012 and A005843.
%C Created to simplify the definition of A129952.
%C a(n) = abs(A009531(n-1)).
%C Starting (1, 2, 1, 4,...): square (1 + x - x^2 - x^3 + x^4 + x^5 - ...) = (1 + 2x - x^2 - 4x^3 + x^4 + 6x^5 - ...).
%C With a(3) taken as 0, a(n+2) = n^k+1 mod 2*n, n>=1, for any k>=2, also for k=n. - _Wolfdieter Lang_, Dec 21 2011
%C Also !(n+2) mod n for n>0 where !n is a subfactorial number (A000166). - _Michel Lagneau_, Sep 05 2012
%C Greatest common divisor of n-1 and (n-1) mod 2. - _Bruno Berselli_, Mar 07 2017
%D Murat Sahin and Elif Tan, Conditional (strong) divisibility sequences, Fib. Q., 56 (No. 1, 2018), 18-31.
%H Vincenzo Librandi, <a href="/A124625/b124625.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (0,2,0,-1).
%F a(n) = 1 for even n, a(n) = n-1 for odd n.
%F a(2*k) = 1, a(2*k+1) = 2*k.
%F G.f.: (1 - x^2 + 2*x^3)/((1 - x)^2*(1 + x)^2).
%F a(n) = (n - (n - 2)*(-1)^n)/2. - _Bruno Berselli_, May 06 2011
%F E.g.f.: 1 + x^2*U(0)/2 where U(k)= 1 + 2*x*(k+1)/(2*k + 3 - x*(2*k+3)/(x + 4*(k+2)*(k+1)/U(k+1)) (continued fraction, 3rd kind, 3-step). - _Sergei N. Gladkovskii_, Oct 20 2012
%F a(n) = 2*floor(n/2) - (n-1)*((n-1) mod 2). - _Wesley Ivan Hurt_, Oct 19 2013
%F a(n) = (n-1)^((1-(-1)^n)/2). - _Wesley Ivan Hurt_, Mar 21 2015
%F a(n) = (n-1) - a(a(n-1))*a(n-1), a(0) = 0. - _Eli Jaffe_, Jun 07 2016
%F E.g.f.: (x + 1)*cosh(x) - sinh(x). - _Ilya Gutkovskiy_, Jun 07 2016
%F a(n) = (-1)^n mod n for n > 0. - _Franz Vrabec_, Mar 06 2020
%F a(n) = (n-1)^(n mod 2). - _Karl V. Keller, Jr._, Aug 01 2020
%p A124625:=n->(n-(n-2)*(-1)^n)/2; seq(A124625(k), k=0..100); # _Wesley Ivan Hurt_, Oct 19 2013
%t Join[{1},Riffle[2Range[0,50],1]] (* _Harvey P. Dale_, Nov 02 2011 *)
%o (PARI) {for(n=0, 85, print1(if(n%2>0, n-1, 1), ","))}
%o (Magma) &cat[[1, 2*k]: k in [0..42]];
%o (Python) print([(n-1)**(n%2) for n in range(0, 86)]) # _Karl V. Keller, Jr._, Jul 26 2020
%Y Cf. A000012 (all 1's), A005843 (even numbers), A009531, A093178, A152271.
%K nonn,easy
%O 0,4
%A _N. J. A. Sloane_, Jun 13 2007
%E More terms from _Klaus Brockhaus_, Jun 16 2007
%E Edited by _N. J. A. Sloane_, May 21 2008 at the suggestion of _R. J. Mathar_
|