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.

A339451 Gray-code-like sequence in which, at each step, the least significant bit that has never been toggled from the previous value, is toggled.

This page as a plain text file.
%I A339451 #16 May 15 2022 07:40:45
%S A339451 0,1,0,2,3,2,0,4,5,4,6,7,6,4,0,8,9,8,10,11,10,8,12,13,12,14,15,14,12,
%T A339451 8,0,16,17,16,18,19,18,16,20,21,20,22,23,22,20,16,24,25,24,26,27,26,
%U A339451 24,28,29,28,30,31,30,28,24,16,0,32,33,32,34,35,34,32,36
%N A339451 Gray-code-like sequence in which, at each step, the least significant bit that has never been toggled from the previous value, is toggled.
%C A339451 Conjectured connections: the position of the bit that is toggled to derive a(n) from a(n-1) is A215020(n); the sequence of absolute differences of this sequence is A182105; there is some underlying connection to the "skew binary" counting system.
%H A339451 Alois P. Heinz, <a href="/A339451/b339451.txt">Table of n, a(n) for n = 0..65535</a>
%e A339451 For n = 18, a(n-1) = 8. That is the second 8 in the sequence. We cannot toggle the 1-bit, because that was already used to derive a(16) = 9 from a(15) = 8, so instead we toggle the 2-bit, yielding a(n) = 10.
%p A339451 a:= proc() local b, a; b:= proc() 1/2 end; a:= proc(n)
%p A339451       option remember; local h; if n=0 then 0 else h:=
%p A339451       a(n-1); b(h):= 2*b(h); Bits[Xor](h, b(h)) fi end
%p A339451     end():
%p A339451 seq(a(n), n=0..127);  # _Alois P. Heinz_, Dec 05 2020
%t A339451 a[m_] := Module[{b, a}, b[_] = 1/2; a[n_] := a[n] =
%t A339451      Module[{h}, If[n == 0 ,  0 ,  h = a[n - 1];
%t A339451      b[h] = 2*b[h]; BitXor[h, b[h]]]]; a[m]];
%t A339451 Table[a[n], {n, 0, 127}] (* _Jean-François Alcover_, May 15 2022, after _Alois P. Heinz_ *)
%Y A339451 Cf. A182105, A215020.
%K A339451 easy,nonn
%O A339451 0,4
%A A339451 _Allan C. Wechsler_, Dec 05 2020