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!)
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. 19

%I #38 Jun 30 2022 08:36:26

%S 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 27,30,26,20,28,31,29,96,32,35,33,37,39,34,38,41,43,46,42,36,44,47,45,

%U 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 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 Antti Karttunen, <a href="/A268717/b268717.txt">Table of n, a(n) for n = 0..8191</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(n) = A003188(A066194(n)) = A003188(1+A006068(n-1)).

%F Other identities. For all n >= 0:

%F A101080(n,a(n+1)) = 1. [The Hamming distance between n and a(n+1) is always one.]

%F A268726(n) = A000523(A003987(n, a(n+1))). [A268726 gives the index of the toggled bit.]

%t 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 (Scheme) (define (A268717 n) (if (zero? n) n (A003188 (A066194 n))))

%o (PARI) A003188(n) = bitxor(n, floor(n/2));

%o A006068(n) = if(n<2, n, {my(m = A006068(floor(n/2))); 2*m + (n%2 + m%2)%2});

%o for(n=0, 100, print1(if(n<1, 0, A003188(1 + A006068(n - 1)))", ")) \\ _Indranil Ghosh_, Mar 31 2017

%o (Python)

%o def A003188(n): return n^(n//2)

%o def A006068(n):

%o if n<2: return n

%o m = A006068(n//2)

%o return 2*m + (n%2 + m%2)%2

%o def a(n): return 0 if n<1 else A003188(1 + A006068(n - 1))

%o print([a(n) for n in range(0, 101)]) # _Indranil Ghosh_, Mar 31 2017

%o (Python)

%o def A268717(n):

%o k, m = n-1, n-1>>1

%o while m > 0:

%o k ^= m

%o m >>= 1

%o return k+1^ k+1>>1 # _Chai Wah Wu_, Jun 29 2022

%Y Inverse: A268718.

%Y Cf. A000523, A003188, A003987, A006068, A066194, A101080, A268726, A268727.

%Y Row 1 and column 1 of array A268715 (without the initial zero).

%Y Row 1 of array A268820.

%Y Cf. A092246 (fixed points).

%Y Cf. A268817 ("square" of this permutation).

%Y Cf. A268821 ("shifted square"), A268823 ("shifted cube") and also A268825, A268827 and A268831 ("shifted higher powers").

%K nonn

%O 0,3

%A _Antti Karttunen_, Feb 12 2016

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 27 04:00 EDT 2024. Contains 372009 sequences. (Running on oeis4.)