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!)
A332782 a(n) = (a(n-1) XOR a(n-5)) + 1, a(0) = a(1) = a(2) = a(3) = a(4) = 0. 3

%I #29 Apr 10 2020 15:12:36

%S 0,0,0,0,0,1,2,3,4,5,5,8,12,9,13,9,2,15,7,11,3,2,14,10,2,2,1,16,27,26,

%T 25,25,10,18,9,17,9,4,23,31,15,7,4,20,12,4,4,1,22,27,32,37,37,52,48,

%U 17,53,17,38,23,7,51,35,6,18,22,38,6,1,20,3,38,33,33,54,54,17,49

%N a(n) = (a(n-1) XOR a(n-5)) + 1, a(0) = a(1) = a(2) = a(3) = a(4) = 0.

%H Alois P. Heinz, <a href="/A332782/b332782.txt">Table of n, a(n) for n = 0..65536</a>.

%H G. Marsaglia, <a href="http://dx.doi.org/10.18637/jss.v008.i14">Xorshift RNGs</a>, Journal of Statistical Software, Vol. 8, Issue 14, Jul 2003.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">Bitwise operation (XOR)</a>.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Linear-feedback_shift_register">Linear-feedback shift register</a>.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Xorshift">Xorshift</a>.

%e a(5) = (a(4) XOR a(0)) + 1 = (0 XOR 0) + 1 = 0 + 1 = 1.

%e a(6) = (a(5) XOR a(1)) + 1 = (1 XOR 0) + 1 = 1 + 1 = 2.

%e a(10) = (a(9) XOR a(5)) + 1 = (101_2 XOR 001_2) + 1 = 100_2 + 1 = 101_2 = 5_10.

%p a:= proc(n) option remember; `if`(n<5, 0,

%p Bits[Xor](a(n-1), a(n-5))+1)

%p end:

%p seq(a(n), n=0..80); # _Alois P. Heinz_, Mar 09 2020

%t Nest[Append[#, 1 + BitXor @@ #[[{-1, -5}]] ] &, ConstantArray[0, 5], 75] (* _Michael De Vlieger_, Feb 23 2020 *)

%o (Python)

%o feedback_delay = 4

%o a = [0 for i in range(feedback_delay+1)]

%o for i in range(feedback_delay,100):

%o a.append((a[i]^a[i-feedback_delay])+1)

%Y Cf. A114375 (shift 1), A332780 (shift 2), A332781 (shift 3).

%K nonn,base

%O 0,7

%A _Rok Cestnik_, Feb 23 2020

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 19 04:12 EDT 2024. Contains 371782 sequences. (Running on oeis4.)