login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A268821
Permutation of nonnegative integers: a(0) = 0, a(n) = A268717(1 + A268717(n-1)).
6
0, 1, 3, 2, 7, 6, 13, 12, 5, 4, 25, 24, 9, 8, 15, 14, 11, 10, 49, 48, 17, 16, 23, 22, 19, 18, 27, 26, 31, 30, 21, 20, 29, 28, 97, 96, 33, 32, 39, 38, 35, 34, 43, 42, 47, 46, 37, 36, 45, 44, 51, 50, 55, 54, 61, 60, 53, 52, 41, 40, 57, 56, 63, 62, 59, 58, 193, 192, 65, 64, 71, 70, 67, 66, 75, 74, 79, 78, 69, 68, 77, 76, 83, 82
OFFSET
0,3
COMMENTS
The "shifted square" of permutation A268717.
FORMULA
a(0) = 0, for n >= 1, a(n) = A268717(1 + A268717(n-1)).
Other identities. For all n >= 0:
A101080(n, a(n+2)) = 2.
MATHEMATICA
A003188[n_]:=BitXor[n, Floor[n/2]]; A006068[n_]:=If[n<2, n, Block[{m = A006068[Floor[n/2]]}, 2m + Mod[Mod[n, 2] + Mod[m, 2], 2]]]; A268717[n_]:=If[n<1, 0, A003188[1 + A006068[n - 1]]]; Table[If[n<2, n, A268717[1 + A268717[n - 1]]], {n, 0, 100}] (* Indranil Ghosh, Apr 01 2017 *)
PROG
(Scheme) (define (A268821 n) (if (zero? n) n (A268717 (+ 1 (A268717 (- n 1))))))
(PARI) A003188(n) = bitxor(n, n\2);
A006068(n) = if(n<2, n, {my(m = A006068(n\2)); 2*m + (n%2 + m%2)%2});
A268717(n) = if(n<1, 0, A003188(1 + A006068(n - 1)));
for(n=0, 100, print1(if(n<2, n, A268717(1 + A268717(n - 1))), ", ")) \\ Indranil Ghosh, Apr 01 2017
(Python)
def A003188(n): return n^(n//2)
def A006068(n):
if n<2: return n
else:
m=A006068(n//2)
return 2*m + (n%2 + m%2)%2
def A268717(n): return 0 if n<1 else A003188(1 + A006068(n - 1))
def a(n): return A268717(1 + A268717(n-1)) if n>0 else 0
print([a(n) for n in range(101)]) # Indranil Ghosh, Apr 01 2017
CROSSREFS
Inverse: A268822.
Row 2 of array A268820.
From term a(2) onward (3, 2, 7, 6, ...) also row 3 of A268715.
Cf. also A101080, A268833.
Sequence in context: A058646 A323635 A125718 * A014841 A056476 A056481
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved