login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A007877 Period 4 zigzag sequence: repeat [0,1,2,1]. 24

%I #112 Jan 25 2024 03:55:55

%S 0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,

%T 2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,

%U 0,1,2,1,0,1,2,1,0,1,2,1,0,1,2,1,0

%N Period 4 zigzag sequence: repeat [0,1,2,1].

%C Euler transform of finite sequence [2,-2,0,1]. - _Michael Somos_, Sep 17 2004

%C This is the r = 2 member in the r-family of sequences S_r(n) defined in A092184 where more information can be found.

%C a(n+1) is the transform of sqrt(1+2x)/sqrt(1-2x) (A063886) under the Chebyshev transformation A(x) -> (1/(1 + x^2))A(x/(1 + x^2)). See also A084099. - _Paul Barry_, Oct 12 2004

%C Multiplicative with a(2) = 2, a(2^e) = 0 if e >= 2, a(p^e) = 1 otherwise. - _David W. Wilson_, Jun 12 2005

%C The e.g.f. of 1, 2, 1, 0, 1, 2, 1, 0, ... (shifted left, offset zero) is exp(x) + sin(x).

%C Binomial transform is A000749(n+2). - _Wesley Ivan Hurt_, Dec 30 2015

%C Decimal expansion of 11/909. - _David A. Corneth_, Dec 12 2016

%C Ternary expansion of 1/5. - _J. Conrad_, Aug 14 2017

%H P. Liu, <a href="/A007877/a007877.pdf">Efficient recognition of integer sequences</a>, Master's Essay, University of Waterloo, Dec. 1994. (Annotated scanned copy)

%H <a href="/index/Ch#Cheby">Index entries for sequences related to Chebyshev polynomials.</a>

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

%F Multiplicative with a(p^e) = 2 if p = 2 and e = 0; 0 if p = 2 and e > 0; 1 if p > 2. - _David W. Wilson_, Aug 01 2001

%F a(n) = -Sum_{k=0..n} (-1)^C(k+2, 2) (Offset -1). - _Paul Barry_, Jul 07 2003

%F a(n) = 1 - cos(n*Pi/2); a(n) = a(n-1) - a(n-2) + a(n-3) for n>2. - Lee Reeves (leereeves(AT)fastmail.fm), May 10 2004

%F a(n) = -a(n-2) + 2, n >= 2, a(0) = 0, a(1) = 1.

%F G.f.: x*(1+x)/((1-x)*(1+x^2)) = x*(1+x)/(1-x+x^2-x^3).

%F a(n) = 1 - T(n, 0) = 1 - A056594(n) with Chebyshev's polynomials T(n, x) of the first kind. Note that T(n, 0) = S(n, 0).

%F a(n) = b(n) + b(n-1), n >= 1, with b(n) := A021913(n+1) the partial sums of S(n,0) = U(n,0) = A056594(n) (Chebyshev's polynomials evaluated at x=0).

%F a(n) = 1 + (1/2){(-1)^[(n-1)/2] - (-1)^[n/2]}. - _Ralf Stephan_, Jun 09 2005

%F Non-reduced g.f.: x*(1+x)^2/(1-x^4). - _Jaume Oliver Lafont_, Mar 27 2009

%F a(n+1) = (S(n, sqrt(2))^2, n >= 0, with the Chebyshev S-polynomials A049310. See the W. Lang link under A181878. - _Wolfdieter Lang_, Dec 15 2010

%F Dirichlet g.f. (1 + 1/2^s - 2/4^s)*zeta(s). - _R. J. Mathar_, Feb 24 2011

%F a(n) = (n mod 4) - (n^3 mod 4) + (n^2 mod 4). - _Gary Detlefs_, Apr 17 2011

%F a(n) = (n mod 2) + 2*floor(((n+1) mod 4)/3). - _Gary Detlefs_, Jul 19 2011

%F a(n) = sqrt(n^2 mod 8). - _Wesley Ivan Hurt_, Jan 01 2014

%F a(n) = (n AND 4*k+2)-(n AND 4*k+1) + 2*floor(((n+2) mod 4)/3), for any k. - _Gary Detlefs_, Jun 08 2014

%F a(n) = Sum_{i=1..n} (-1)^floor((i-1)/2). - _Wesley Ivan Hurt_, Dec 26 2015

%F a(n) = a(n-4) for n >= 4. - _Wesley Ivan Hurt_, Sep 07 2022

%F a(n) = n - 2*floor(n/4) - 2*floor((n+1)/4). - _Ridouane Oudra_, Jan 22 2024

%p A007877:=n->sqrt(n^2 mod 8); seq(A007877(n), n=0..100); # _Wesley Ivan Hurt_, Jan 01 2014

%t f[n_] := Mod[n, 4] - Mod[n^3, 4] + Mod[n^2, 4] (* Or *)

%t f[n_] := Mod[n, 2] + 2 Floor[Mod[n + 1, 4]/3] (* Or *)

%t f[n_] := Switch[Mod[n, 4], 0, 0, 1, 1, 2, 2, 3, 1]; Array[f, 105, 0] (* _Robert G. Wilson v_, Aug 08 2011 *)

%t Table[Sqrt[Mod[n^2,8]], {n,0,100}] (* _Wesley Ivan Hurt_, Jan 01 2014 *)

%t LinearRecurrence[{1, -1, 1}, {0, 1, 2}, 80] (* _Vincenzo Librandi_, Dec 27 2015 *)

%t PadRight[{},100,{0,1,2,1}] (* _Harvey P. Dale_, Oct 24 2023 *)

%o (PARI) a(n)=[0,1,2,1][1+n%4] \\ _Jaume Oliver Lafont_, Mar 27 2009

%o (PARI) concat(0, Vec(x*(1+x)/(1-x+x^2-x^3) + O(x^100))) \\ _Altug Alkan_, Dec 29 2015

%o (Magma) &cat [[0,1,2,1]^^25]; // _Vincenzo Librandi_, Dec 27 2015

%o (Python)

%o def A007877(n): return (0,1,2,1)[n&3] # _Chai Wah Wu_, Jan 26 2023

%Y Cf. A000749, A021913, A049310, A056594, A063886, A084099, A092184, A181878.

%Y Period k zigzag sequences: A000035 (k=2), this sequence (k=4), A260686 (k=6), A266313 (k=8), A271751 (k=10), A271832 (k=12), A279313 (k=14), A279319 (k=16), A158289 (k=18).

%K nonn,easy,mult

%O 0,3

%A Christopher Lam Cham Kee (Topher(AT)CyberDude.Com)

%E Chebyshev comments from _Wolfdieter Lang_, Sep 10 2004

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 11:06 EDT 2024. Contains 371905 sequences. (Running on oeis4.)