login
A158289
Period 18 zigzag sequence: repeat [0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1].
14
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5
OFFSET
0,3
COMMENTS
A toothed or zigzag sequence.
Sequence contains only numbers 0..9; abs(a(n+1)-a(n)) = 1.
Decimal expansion of 12345679/1000000001. - Elmo R. Oliveira, Feb 20 2024
LINKS
FORMULA
a(18*k+j) = a(18*(k+1)-j) = j for k >= 0, j = 0..9.
G.f.: x*(1+x+x^2)*(1+x^3+x^6)/((1-x)*(1+x)*(1-x+x^2)*(1-x^3+x^6)). - Klaus Brockhaus, Sep 07 2009
a(n) = Sum_{i=0..n-1} (-1)^floor(i/9). - Wesley Ivan Hurt, Jul 25 2015
a(n) = abs(n - 18*round(n/18)). - Wesley Ivan Hurt, Dec 10 2016
a(n) = a(n-18) for n >= 18. - Wesley Ivan Hurt, Sep 07 2022
MATHEMATICA
a[n_] := If[m = Mod[n, 18]; m <= 9, m, 18-m]; Table[a[n], {n, 0, 85}] (* Jean-François Alcover, Jul 19 2013 *)
PadRight[{}, 100, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1}] (* Vincenzo Librandi, Jul 26 2015 *)
PROG
(Magma) [ s lt 9 select r else 9-r where r is n mod 9 where s is n mod 18: n in [0..104] ]; // Klaus Brockhaus, Sep 07 2009
(Magma) S:=[]; a:=0; for n in [0..104] do Append(~S, a); if n mod 18 eq 0 then d:=1; else if n mod 9 eq 0 then d:=-1; end if; end if; a+:=d; end for; S; // Klaus Brockhaus, Sep 07 2009
(Magma) &cat[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]: n in [0..5]]; // Vincenzo Librandi, Jul 26 2015
(PARI) a(n)=abs(n-round(n/18)*18) \\ M. F. Hasler, Jul 27 2015
CROSSREFS
Cf. A068073 (repeat 1,2,3,2), A028356 (repeat 1,2,3,4,3,2), A130784 (repeat 1,3,2).
Period k zigzag sequences: A000035 (k=2), A007877 (k=4), A260686 (k=6), A266313 (k=8), A271751 (k=10), A271832 (k=12), A279313 (k=14), A279319 (k=16), this sequence (k=18).
Sequence in context: A028902 A081598 A232360 * A213652 A262734 A287794
KEYWORD
easy,nonn
AUTHOR
Jaroslav Krizek, Mar 15 2009
EXTENSIONS
Edited and extended by Klaus Brockhaus, Sep 07 2009
STATUS
approved