login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A105198 a(n) = n(n+1)/2 mod 4. 16
0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0, 1, 3, 2, 2, 3, 1, 0, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

0,1,3,2,2,3,1,0 repeated indefinitely.

If N is any power of 2 then n(n+1)/2 mod N is a repeating pattern of length 2N. Moreover, the first N digits form a permutation P of A={0,1,...,N-1}. The subsequent N digits are P in the reversed order. The technique is useful for the generation of arbitrarily large pseudo-random permutations.

LINKS

Antti Karttunen, Table of n, a(n) for n = 0..8191

O. Y. Takeshita and D. J. Costello, Jr., New Deterministic Interleaver Designs for Turbo-Codes, IEEE Trans. Inform. Theory, vol. 46, no. 6, pp. 1988-2006, Sept. 2000.

Index entries for linear recurrences with constant coefficients, signature (1,-1,1,-1,1,-1,1).

FORMULA

From Paul Barry, Jul 26 2005: (Start)

G.f.: (x + 2x^2 + 2x^4 + x^5)/(1 - x + x^2 - x^3 + x^4 - x^5 + x^6 - x^7).

a(n) = a(n-1) - a(n-2) + a(n-3) - a(n-4) + a(n-5) - a(n-6) + a(n-7).

a(n) = cos(3*Pi*n/4 + Pi/4)/2 + (1/2 - sqrt(2)/2)*sin(3*Pi*n/4 + Pi/4) - (1/2 + sqrt(2)/2)*cos(Pi*n/4 + Pi/4) - sin(Pi*n/4 + Pi/4)/2 - cos(Pi*n/2)/2 + sin(Pi*n/2)/2 + 3/2. (End)

a(n) = (1/56)*(3*(n mod 8) + 10*((n+1) mod 8) + 17*((n+2) mod 8) - 4*((n+3) mod 8) + 3*((n+4) mod 8) + 10*((n+5) mod 8) - 11*((n+6) mod 8) - 4*((n+7) mod 8)). - Paolo P. Lava, Jul 16 2008

a(n) = (((n+1)^5 - n^5 - 1) mod 120)/30. - Gary Detlefs, Mar 25 2012

a(n) = -ceiling(n/2)*(-1)^n mod 4. - Wesley Ivan Hurt, Jul 13 2014

MAPLE

for n from 0 to 300 do printf(`%d, `, n*(n+1)/2 mod 4) od: # James A. Sellers, Apr 21 2005

A105198:=n->-ceil(n/2)*(-1)^n mod 4: seq(A105198(n), n=0..100); # Wesley Ivan Hurt, Jul 13 2014

MATHEMATICA

Table[Mod[-Ceiling[n/2] (-1)^n, 4], {n, 0, 100}] (* Wesley Ivan Hurt, Jul 13 2014 *)

PROG

(MAGMA) [ -Ceiling(n/2)*(-1)^n mod 4 : n in [0..100]]; // Wesley Ivan Hurt, Jul 13 2014

(PARI) Vec((x+2*x^2+2*x^4+x^5)/(1-x+x^2-x^3+x^4-x^5+x^6-x^7) + O(x^90)) \\ Michel Marcus, Jul 13 2014

(Scheme) (define (A105198 n) (modulo (* 1/2 n (+ 1 n)) 4)) ;; Antti Karttunen, Aug 10 2017

CROSSREFS

Cf. triangular numbers A000217, A105332-A105340.

One less than A110549, A133882 shifted once right, with zero inserted to front.

Sequence in context: A328829 A006379 A217956 * A133882 A092106 A278885

Adjacent sequences:  A105195 A105196 A105197 * A105199 A105200 A105201

KEYWORD

nonn,easy

AUTHOR

Oscar Takeshita, Apr 11 2005

EXTENSIONS

More terms from James A. Sellers, Apr 21 2005

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 27 02:46 EST 2020. Contains 331291 sequences. (Running on oeis4.)