cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-5 of 5 results.

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

Original entry on oeis.org

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, 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, 17, 53, 17, 38, 23, 7, 51, 35, 6, 18, 22, 38, 6, 1, 20, 3, 38, 33, 33, 54, 54, 17, 49
Offset: 0

Views

Author

Rok Cestnik, Feb 23 2020

Keywords

Examples

			a(5) = (a(4) XOR a(0)) + 1 = (0 XOR 0) + 1 = 0 + 1 = 1.
a(6) = (a(5) XOR a(1)) + 1 = (1 XOR 0) + 1 = 1 + 1 = 2.
a(10) = (a(9) XOR a(5)) + 1 = (101_2 XOR 001_2) + 1 = 100_2 + 1 = 101_2 = 5_10.
		

Crossrefs

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

Programs

  • Maple
    a:= proc(n) option remember; `if`(n<5, 0,
           Bits[Xor](a(n-1), a(n-5))+1)
        end:
    seq(a(n), n=0..80);  # Alois P. Heinz, Mar 09 2020
  • Mathematica
    Nest[Append[#, 1 + BitXor @@ #[[{-1, -5}]] ] &, ConstantArray[0, 5], 75] (* Michael De Vlieger, Feb 23 2020 *)
  • Python
    feedback_delay = 4
    a = [0 for i in range(feedback_delay+1)]
    for i in range(feedback_delay,100):
        a.append((a[i]^a[i-feedback_delay])+1)

A182536 a(0)=0, a(1)=1, a(n)=(a(n-1) XOR a(n-2)) + n.

Original entry on oeis.org

0, 1, 3, 5, 10, 20, 36, 55, 27, 53, 56, 24, 44, 65, 123, 73, 66, 28, 112, 127, 35, 113, 104, 48, 112, 89, 67, 53, 146, 196, 116, 207, 219, 53, 272, 328, 124, 345, 331, 57, 410, 460, 128, 375, 547, 897, 464, 640, 896, 305, 739, 1029, 1818, 852, 1156, 2055, 3259, 1269, 2184, 3256, 1132, 2321, 3515, 1257, 2450, 3516, 1136, 2575
Offset: 0

Views

Author

Alex Ratushnyak, May 04 2012

Keywords

Crossrefs

Programs

  • Python
    prpr, prev = 0,1
    for n in range(2,99):
        current = (prpr ^ prev) + n
        print(prpr, end=', ')
        prpr, prev = prev, current

Formula

a(0)=0, a(1)=1, a(n)=(a(n-1) XOR a(n-2)) + n, where XOR is the bitwise exclusive-or operator.

A332780 a(n) = (a(n-1) XOR a(n-3)) + 1, a(0) = a(1) = a(2) = 0.

Original entry on oeis.org

0, 0, 0, 1, 2, 3, 3, 2, 2, 2, 1, 4, 7, 7, 4, 4, 4, 1, 6, 3, 3, 6, 6, 6, 1, 8, 15, 15, 8, 8, 8, 1, 10, 3, 3, 10, 10, 10, 1, 12, 7, 7, 12, 12, 12, 1, 14, 3, 3, 14, 14, 14, 1, 16, 31, 31, 16, 16, 16, 1, 18, 3, 3, 18, 18, 18, 1, 20, 7, 7, 20, 20, 20, 1, 22, 3, 3, 22, 22, 22
Offset: 0

Views

Author

Rok Cestnik, Feb 23 2020

Keywords

Examples

			a(3) = (a(2) XOR a(0)) + 1 = (0 XOR 0) + 1 = 0 + 1 = 1.
a(4) = (a(3) XOR a(1)) + 1 = (1 XOR 0) + 1 = 1 + 1 = 2.
a(6) = (a(5) XOR a(3)) + 1 = (11_2 XOR 01_2) + 1 = 10_2 + 1 = 11_2 = 3_10.
		

Crossrefs

Cf. A114375 (shift 1), A332781 (shift 3), A332782 (shift 4).

Programs

  • Mathematica
    Nest[Append[#, 1 + BitXor @@ #[[{-1, -3}]] ] &, ConstantArray[0, 3], 75] (* Michael De Vlieger, Feb 23 2020 *)
  • Python
    feedback_delay = 2
    a = [0 for i in range(feedback_delay+1)]
    for i in range(feedback_delay,100):
        a.append((a[i]^a[i-feedback_delay])+1)

Formula

a(3+7*i) = 1; i >= 0.
a(3+7*i-{1,2,3,6}) = 2*i; i >= 0.
a(3+7*2^j*(1+2*i)-{4,5}) = 2^(j+2)-1; j >= 0, i >= 0.

A332781 a(n) = (a(n-1) XOR a(n-4)) + 1, a(0) = a(1) = a(2) = a(3) = 0.

Original entry on oeis.org

0, 0, 0, 0, 1, 2, 3, 4, 6, 5, 7, 4, 3, 7, 1, 6, 6, 2, 4, 3, 6, 5, 2, 2, 5, 1, 4, 7, 3, 3, 8, 16, 20, 24, 17, 2, 23, 16, 2, 1, 23, 8, 11, 11, 29, 22, 30, 22, 12, 27, 6, 17, 30, 6, 1, 17, 16, 23, 23, 7, 24, 16, 8, 16, 9, 26, 19, 4, 14, 21, 7, 4, 11, 31, 25, 30, 22, 10, 20
Offset: 0

Views

Author

Rok Cestnik, Feb 23 2020

Keywords

Comments

Exclusive or (XOR) is a natural operation for computers. When combined with delayed feedback it can yield very complex behavior, which can be utilized for pseudorandom number generation [Marsaglia 2003]. Such "linear-feedback shift register" schemes can be implemented with basic computer operations and are hence very fast. Their behavior is typically periodic with long periods. Analogous procedures are used to generate this sequence, which takes a delayed feedback XOR and adds 1 at each iteration. It appears to be growing, although existence of loops has not been excluded.

Examples

			a(4) = (a(3) XOR a(0)) + 1 = (0 XOR 0) + 1 = 0 + 1 = 1.
a(5) = (a(4) XOR a(1)) + 1 = (1 XOR 0) + 1 = 1 + 1 = 2.
a(8) = (a(7) XOR a(4)) + 1 = (100_2 XOR 001_2) + 1 = 101_2 + 1 = 110_2 = 6_10.
		

Crossrefs

Cf. A114375 (shift 1), A332780 (shift 2), A332782 (shift 4).

Programs

  • Mathematica
    Nest[Append[#, 1 + BitXor @@ #[[{-1, -4}]] ] &, ConstantArray[0, 4], 75] (* Michael De Vlieger, Feb 23 2020 *)
  • Python
    feedback_delay = 3
    a = [0 for i in range(feedback_delay+1)]
    for i in range(feedback_delay,100):
        a.append((a[i]^a[i-feedback_delay])+1)

A339602 a(n) = (a(n-2) XOR A030101(a(n-1))) + 1, a(0) = 0, a(1) = 1.

Original entry on oeis.org

0, 1, 2, 1, 4, 1, 6, 3, 6, 1, 8, 1, 10, 5, 16, 5, 22, 9, 32, 9, 42, 29, 62, 3, 62, 29, 42, 9, 36, 1, 38, 25, 54, 3, 54, 25, 38, 1, 40, 5, 46, 25, 62, 7, 58, 17, 44, 29, 60, 19, 38, 11, 44, 7, 44, 11, 34, 27, 58, 13, 50, 31, 46, 3, 46, 31, 50, 13, 58, 27, 34
Offset: 0

Views

Author

Thomas Scheuerle, Dec 09 2020

Keywords

Comments

Is this sequence periodic? The related sequence A114375 was found to be nonperiodic, however the same argument does not hold here as the bitreversal operation used here maps different values onto the same. E.g. 111000 -> 111 111 -> 111. Every time this sequence develops a not yet seen value a(n) = 2^m, the space of combinations increases from (2^(m-1))^2 to (2^m)^2 reducing the probability to hit an already seen pair of values for [a(n-2),a(n-1)].
This sequence contains some palindromic parts. Example a(55)..a(72): 11, 34, 27, 58, 13, 50, 31, 46, 3, 46, 31, 50, 13, 58, 27, 34, 11.
a(n) <> a(n-1). a(2k) = 2m. a(2k+1) = 2m+1.
a(n) = 2^k, k > 0 for each k will exist only once in this sequence, if it is never periodic. In this case the 2^k will be in increasing sequence ordered.
Conjecture: Let p be an odd number, then a(n) = p will be more frequently found in this sequence than a(n) = p+1 (tested for n = 0..10^7 with primes > 2, but seems to be true for all odd too).

Examples

			a(5) = 1 binary: 1; a(6) = 6 binary: 110, binary bitreversed: 11;
so a(7) = binary: (001 XOR 11)+1 = 11 decimal: 3.
		

Crossrefs

Programs

  • MATLAB
    function a = calc_A339602(length)
        % a(0) = 0  not in output of program
        a(1) = 1; % part of definition
        an_2 = 0; % a(0)
        an_1 = a(1);
        for n = 2:length
            an_1_old = an_1;
            an_1 = bitxor(an_2,bitreverse(an_1))+1;
            an_2 = an_1_old;
            a(n) = an_1;
        end
    end
    function r = bitreverse(k) % A030101(k)
        r = 0;
        m = floor(log2(k))+1;
        for i = 1:m
            r = bitset(r,m-i+1,bitget(k,i));
        end
    end
    
  • Maple
    bitrev:= proc(n) local L,i;
      L:= convert(n,base,2);
      add(L[-i]*2^(i-1),i=1..nops(L))
    end proc:
    A:= Array(0..100):
    A[0]:= 0: A[1]:= 1:
    for n from 2 to 100 do
      A[n]:= Bits:-Xor(A[n-2],bitrev(A[n-1]))+1
    od:
    seq(A[i],i=0..100); # Robert Israel, Dec 25 2020
  • Mathematica
    f[n_] := FromDigits[Reverse @ IntegerDigits[n, 2], 2]; a[0] = 0; a[1] = 1; a[n_] := a[n] = BitXor[a[n - 2], f[a[n - 1]]] + 1; Array[a, 100, 0] (* Amiram Eldar, Dec 10 2020 *)
  • PARI
    f(n) = fromdigits(Vecrev(binary(n)), 2); \\ A030101
    lista(nn) = {my(x=0, y=1); print1(x, ", ", y, ", "); for (n=2, nn, z = bitxor(x, f(y)) +1; print1(z, ", "); x = y; y = z;);} \\ Michel Marcus, Dec 10 2020
Showing 1-5 of 5 results.