%I #24 May 09 2021 07:54:58
%S 0,7,14,15,28,31,30,27,56,63,62,63,60,63,54,51,112,119,126,127,124,
%T 127,126,123,120,127,126,127,108,111,102,99,224,231,238,239,252,255,
%U 254,251,248,255,254,255,252,255,246,243,240,247,254,255,252,255,254,251,216,223,222,223,204,207,198,195,448,455,462
%N Formula for Wolfram's Rule 126 cellular automaton: a(n) = (n XOR 2n) OR (n XOR 4n).
%H Antti Karttunen, <a href="/A269173/b269173.txt">Table of n, a(n) for n = 0..8191</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Rule126.html">Rule 126</a>
%H S. Wolfram, <a href="http://wolframscience.com/">A New Kind of Science</a>
%H <a href="/index/Ce#cell">Index entries for sequences related to cellular automata</a>
%H <a href="https://oeis.org/wiki/Index_to_Elementary_Cellular_Automata">Index to Elementary Cellular Automata</a>
%F a(n) = A048724(n) OR A048725(n) = (n XOR 2n) OR (n XOR 4n), where OR is a bitwise-or (A003986) and XOR is A003987.
%F Other identities. For all n >= 0:
%F a(2*n) = 2*a(n).
%F a(n) = A057889(a(A057889(n))). [Rule 126 is amphichiral (symmetric).]
%e a(4) = (4 XOR 2*4) OR (4 XOR 4*4) = 12 OR 20 = 28. - _Indranil Ghosh_, Apr 02 2017
%t Table[BitOr[BitXor[n, 2n], BitXor[n, 4n]], {n, 0, 100}] (* _Indranil Ghosh_, Apr 02 2017 *)
%o (Scheme) (define (A269173 n) (A003986bi (A048724 n) (A048725 n)))
%o (PARI) for(n=0, 100, print1(bitor(bitxor(n, 2*n), bitxor(n, 4*n)),", ")) \\ _Indranil Ghosh_, Apr 02 2017
%o (Python) print([(n^(2*n))|(n^(4*n)) for n in range(101)]) # _Indranil Ghosh_, Apr 02 2017
%o (C)
%o #include <stdio.h>
%o int main()
%o {
%o int n;
%o for(n=0; n<=100; n++){
%o printf("%d, ",(n^(2*n))|(n^(4*n)));
%o }
%o return 0;
%o } /* _Indranil Ghosh_, Apr 02 2017 */
%Y Cf. A003986, A003987, A048724, A048725, A057889.
%Y Cf. A267365 (iterates starting from 1).
%Y Cf. A269174.
%K nonn
%O 0,2
%A _Antti Karttunen_, Feb 22 2016
|