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.

A268717 Permutation of natural numbers: a(0) = 0, a(n) = A003188(1+A006068(n-1)), where A003188 is binary Gray code and A006068 is its inverse.

This page as a plain text file.
%I A268717 #47 Jun 09 2025 22:00:10
%S A268717 0,1,3,6,2,12,4,7,5,24,8,11,9,13,15,10,14,48,16,19,17,21,23,18,22,25,
%T A268717 27,30,26,20,28,31,29,96,32,35,33,37,39,34,38,41,43,46,42,36,44,47,45,
%U A268717 49,51,54,50,60,52,55,53,40,56,59,57,61,63,58,62,192,64,67,65,69,71,66,70,73,75,78,74,68,76,79,77,81
%N A268717 Permutation of natural numbers: a(0) = 0, a(n) = A003188(1+A006068(n-1)), where A003188 is binary Gray code and A006068 is its inverse.
%H A268717 Antti Karttunen, <a href="/A268717/b268717.txt">Table of n, a(n) for n = 0..8191</a>
%H A268717 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A268717 a(n) = A003188(A066194(n)) = A003188(1+A006068(n-1)).
%F A268717 Other identities. For all n >= 0:
%F A268717 A101080(n,a(n+1)) = 1. [The Hamming distance between n and a(n+1) is always one.]
%F A268717 A268726(n) = A000523(A003987(n, a(n+1))). [A268726 gives the index of the toggled bit.]
%F A268717 From _Alan Michael Gómez Calderón_, May 29 2025: (Start)
%F A268717 a(2*n) = (2*n-1) XOR (2-A010060(n-1)) for n >= 1;
%F A268717 a(n) = (A268718(n-1)-1) XOR (A171977(n-1)+1) for n >= 2. (End)
%t A268717 A003188[n_] := BitXor[n, Floor[n/2]]; A006068[n_] := If[n == 0, 0, BitXor @@ Table[Floor[n/2^m], {m, 0, Floor[Log[2, n]]}]]; a[n_] := If[n == 0, 0, A003188[1 + A006068[n-1]]]; Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Feb 23 2016 *)
%o A268717 (Scheme) (define (A268717 n) (if (zero? n) n (A003188 (A066194 n))))
%o A268717 (PARI) A003188(n) = bitxor(n, floor(n/2));
%o A268717 A006068(n) = if(n<2, n, {my(m = A006068(floor(n/2))); 2*m + (n%2 + m%2)%2});
%o A268717 for(n=0, 100, print1(if(n<1, 0, A003188(1 + A006068(n - 1)))", ")) \\ _Indranil Ghosh_, Mar 31 2017
%o A268717 (Python)
%o A268717 def A003188(n): return n^(n//2)
%o A268717 def A006068(n):
%o A268717     if n<2: return n
%o A268717     m = A006068(n//2)
%o A268717     return 2*m + (n%2 + m%2)%2
%o A268717 def a(n): return 0 if n<1 else A003188(1 + A006068(n - 1))
%o A268717 print([a(n) for n in range(0, 101)]) # _Indranil Ghosh_, Mar 31 2017
%o A268717 (Python)
%o A268717 def A268717(n):
%o A268717     k, m = n-1, n-1>>1
%o A268717     while m > 0:
%o A268717         k ^= m
%o A268717         m >>= 1
%o A268717     return k+1^ k+1>>1 # _Chai Wah Wu_, Jun 29 2022
%Y A268717 Inverse: A268718.
%Y A268717 Cf. A000523, A003188, A003987, A006068, A010060, A066194, A101080, A171977, A268718, A268726, A268727.
%Y A268717 Row 1 and column 1 of array A268715 (without the initial zero).
%Y A268717 Row 1 of array A268820.
%Y A268717 Cf. A092246 (fixed points).
%Y A268717 Cf. A268817 ("square" of this permutation).
%Y A268717 Cf. A268821 ("shifted square"), A268823 ("shifted cube") and also A268825, A268827 and A268831 ("shifted higher powers").
%K A268717 nonn
%O A268717 0,3
%A A268717 _Antti Karttunen_, Feb 12 2016