[go: up one dir, main page]

login
Search: a268825 -id:a268825
     Sort: relevance | references | number | modified | created      Format: long | short | data
Permutation of nonnegative integers: a(0) = 0, a(n) = A268717(1+A268825(n-1)).
+20
6
0, 1, 3, 2, 6, 7, 5, 12, 4, 10, 14, 13, 15, 30, 26, 25, 27, 11, 9, 24, 8, 54, 50, 49, 51, 19, 17, 48, 16, 31, 29, 20, 28, 18, 22, 21, 23, 102, 98, 97, 99, 35, 33, 96, 32, 47, 45, 36, 44, 34, 38, 37, 39, 55, 53, 60, 52, 58, 62, 61, 63, 46, 42, 41, 43, 59, 57, 40, 56, 198, 194, 193, 195, 67, 65, 192, 64, 79, 77, 68, 76, 66, 70, 69, 71, 87
OFFSET
0,3
COMMENTS
The "fifth shifted power" of permutation A268717.
FORMULA
a(0) = 0, for n >= 1, a(n) = A268717(1+A268825(n-1)).
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]]]; A268823[n_]:= If[n<2, n, A268717[1 + A268717[1 + A268717[n - 2]]]]; A268825[n_]:=If[n<1, 0, A268717[1 + A268823[n - 1]]]; A268827[n_]:=If[n<1, 0, A268717[1 + A268825[n - 1]]]; Table[A268827[n], {n, 0, 100}] (* Indranil Ghosh, Apr 03 2017 *)
PROG
(Scheme) (define (A268827 n) (if (zero? n) n (A268717 (+ 1 (A268825 (- 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)));
A268823(n) = if(n<2, n, A268717(1 + A268717(1 + A268717(n - 2))));
A268825(n) = if(n<1, 0, A268717(1+A268823(n - 1)));
for(n=0, 100, print1(if(n<1, 0, A268717(1+A268825(n - 1))), ", ")) \\ Indranil Ghosh, Apr 03 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 A268823(n): return A268717(1 + A268717(1 + A268717(n - 2))) if n>1 else n
def A268825(n): return A268717(1 + A268823(n - 1)) if n>0 else 0
def a(n): return A268717(1 + A268825(n - 1)) if n>0 else 0
print([a(n) for n in range(101)]) # Indranil Ghosh, Apr 03 2017
CROSSREFS
Inverse: A268828.
Row 5 of array A268820.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved
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.
+10
19
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, 27, 30, 26, 20, 28, 31, 29, 96, 32, 35, 33, 37, 39, 34, 38, 41, 43, 46, 42, 36, 44, 47, 45, 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
OFFSET
0,3
FORMULA
a(n) = A003188(A066194(n)) = A003188(1+A006068(n-1)).
Other identities. For all n >= 0:
A101080(n,a(n+1)) = 1. [The Hamming distance between n and a(n+1) is always one.]
A268726(n) = A000523(A003987(n, a(n+1))). [A268726 gives the index of the toggled bit.]
MATHEMATICA
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 *)
PROG
(Scheme) (define (A268717 n) (if (zero? n) n (A003188 (A066194 n))))
(PARI) A003188(n) = bitxor(n, floor(n/2));
A006068(n) = if(n<2, n, {my(m = A006068(floor(n/2))); 2*m + (n%2 + m%2)%2});
for(n=0, 100, print1(if(n<1, 0, A003188(1 + A006068(n - 1)))", ")) \\ Indranil Ghosh, Mar 31 2017
(Python)
def A003188(n): return n^(n//2)
def A006068(n):
if n<2: return n
m = A006068(n//2)
return 2*m + (n%2 + m%2)%2
def a(n): return 0 if n<1 else A003188(1 + A006068(n - 1))
print([a(n) for n in range(0, 101)]) # Indranil Ghosh, Mar 31 2017
(Python)
def A268717(n):
k, m = n-1, n-1>>1
while m > 0:
k ^= m
m >>= 1
return k+1^ k+1>>1 # Chai Wah Wu, Jun 29 2022
CROSSREFS
Inverse: A268718.
Row 1 and column 1 of array A268715 (without the initial zero).
Row 1 of array A268820.
Cf. A092246 (fixed points).
Cf. A268817 ("square" of this permutation).
Cf. A268821 ("shifted square"), A268823 ("shifted cube") and also A268825, A268827 and A268831 ("shifted higher powers").
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 12 2016
STATUS
approved
Square array A(r,c): A(0,c) = c, A(r,0) = 0, A(r>=1,c>=1) = A003188(1+A006068(A(r-1,c-1))) = A268717(1+A(r-1,c-1)), read by descending antidiagonals as A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), A(2,0), ...
+10
13
0, 1, 0, 2, 1, 0, 3, 3, 1, 0, 4, 6, 3, 1, 0, 5, 2, 2, 3, 1, 0, 6, 12, 7, 2, 3, 1, 0, 7, 4, 6, 6, 2, 3, 1, 0, 8, 7, 13, 5, 6, 2, 3, 1, 0, 9, 5, 12, 7, 7, 6, 2, 3, 1, 0, 10, 24, 5, 15, 4, 7, 6, 2, 3, 1, 0, 11, 8, 4, 13, 5, 5, 7, 6, 2, 3, 1, 0, 12, 11, 25, 4, 14, 12, 5, 7, 6, 2, 3, 1, 0, 13, 9, 24, 12, 15, 4, 4, 5, 7, 6, 2, 3, 1, 0, 14, 13, 9, 27, 12, 10, 13, 4, 5, 7, 6, 2, 3, 1, 0
OFFSET
0,4
FORMULA
For row zero: A(0,k) = k, for column zero: A(n,0) = 0, and in other cases: A(n,k) = A003188(1+A006068(A(n-1,k-1)))
Other identities. For all n >= 0:
A(n,n) = A003188(n).
A(A006068(n),A006068(n)) = n.
EXAMPLE
The top left [0 .. 16] x [0 .. 19] section of the array:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
0, 1, 3, 6, 2, 12, 4, 7, 5, 24, 8, 11, 9, 13, 15, 10, 14, 48, 16, 19
0, 1, 3, 2, 7, 6, 13, 12, 5, 4, 25, 24, 9, 8, 15, 14, 11, 10, 49, 48
0, 1, 3, 2, 6, 5, 7, 15, 13, 4, 12, 27, 25, 8, 24, 14, 10, 9, 11, 51
0, 1, 3, 2, 6, 7, 4, 5, 14, 15, 12, 13, 26, 27, 24, 25, 10, 11, 8, 9
0, 1, 3, 2, 6, 7, 5, 12, 4, 10, 14, 13, 15, 30, 26, 25, 27, 11, 9, 24
0, 1, 3, 2, 6, 7, 5, 4, 13, 12, 11, 10, 15, 14, 31, 30, 27, 26, 9, 8
0, 1, 3, 2, 6, 7, 5, 4, 12, 15, 13, 9, 11, 14, 10, 29, 31, 26, 30, 8
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 14, 15, 8, 9, 10, 11, 28, 29, 30, 31
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 10, 14, 24, 8, 11, 9, 20, 28, 31
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 11, 10, 25, 24, 9, 8, 21, 20
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 9, 11, 27, 25, 8, 24, 23
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 8, 9, 26, 27, 24, 25
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 24, 8, 30, 26, 25
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 25, 24, 31, 30
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 27, 25, 29
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 26, 27
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]]]; a[r_, 0]:= 0; a[0, c_]:=c; a[r_, c_]:= A003188[1 + A006068[a[r - 1, c - 1]]]; Table[a[c, r - c], {r, 0, 15}, {c, 0, r}] //Flatten (* Indranil Ghosh, Apr 02 2017 *)
PROG
(Scheme)
(define (A268820 n) (A268820bi (A002262 n) (A025581 n)))
(define (A268820bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (A268717 (+ 1 (A268820bi (- row 1) (- col 1)))))))
(define (A268820bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (A003188 (+ 1 (A006068 (A268820bi (- row 1) (- col 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});
a(r, c) = if(r==0, c, if(c==0, 0, A003188(1 + A006068(a(r - 1, c - 1)))));
for(r=0, 15, for(c=0, r, print1(a(c, r - c), ", "); ); print(); ); \\ Indranil Ghosh, Apr 02 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 a(r, c): return c if r<1 else 0 if c<1 else A003188(1 + A006068(a(r - 1, c - 1)))
for r in range(16):
print([a(c, r - c) for c in range(r + 1)]) # Indranil Ghosh, Apr 02 2017
CROSSREFS
Inverses of these permutations can be found in table A268830.
Row 0: A001477, Row 1: A268717, Row 2: A268821, Row 3: A268823, Row 4: A268825, Row 5: A268827, Row 6: A268831, Row 7: A268933.
Rows converge towards A003188, which is also the main diagonal.
Cf. array A268715 (can be extracted from this one).
Cf. array A268833 (shows related Hamming distances with regular patterns).
KEYWORD
nonn,tabl
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved
Permutation of nonnegative integers: a(0) = 0, a(n) = A268717(1 + A268821(n-1)).
+10
10
0, 1, 3, 2, 6, 5, 7, 15, 13, 4, 12, 27, 25, 8, 24, 14, 10, 9, 11, 51, 49, 16, 48, 22, 18, 17, 19, 26, 30, 29, 31, 23, 21, 28, 20, 99, 97, 32, 96, 38, 34, 33, 35, 42, 46, 45, 47, 39, 37, 44, 36, 50, 54, 53, 55, 63, 61, 52, 60, 43, 41, 56, 40, 62, 58, 57, 59, 195, 193, 64, 192, 70, 66, 65, 67, 74, 78, 77, 79, 71, 69, 76, 68, 82, 86, 85
OFFSET
0,3
COMMENTS
The "third shifted power" of permutation A268717.
FORMULA
a(0), for n >= 1, a(n) = A268717(1 + A268821(n-1)).
a(0) = 0, a(1) = 1, and for n > 1, a(n) = A268717(1 + A268717(1 + A268717(n-2))).
For n >= 3, a(n) = A003188(3+A006068(n-3)). - Antti Karttunen, Mar 11 2024
PROG
(Scheme) (define (A268823 n) (if (<= n 1) n (A268717 (+ 1 (A268717 (+ 1 (A268717 (- n 2))))))))
(PARI) A003188(n) = bitxor(n, floor(n/2));
A006068(n) = if(n<2, n, {my(m = A006068(floor(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(1 + A268717(n - 2)))), ", ")) \\ Indranil Ghosh, Mar 31 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(1 + A268717(n - 2))) if n>1 else n
print([a(n) for n in range(101)]) # Indranil Ghosh, Mar 31 2017
CROSSREFS
Inverse: A268824.
Row 3 of array A268820.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved
Permutation of nonnegative integers: a(0) = 0, a(n) = 1 + A268824(A268718(n)-1).
+10
6
0, 1, 3, 2, 6, 7, 4, 5, 18, 19, 16, 17, 10, 11, 8, 9, 26, 27, 24, 25, 34, 35, 32, 33, 14, 15, 12, 13, 30, 31, 28, 29, 42, 43, 40, 41, 50, 51, 48, 49, 62, 63, 60, 61, 46, 47, 44, 45, 22, 23, 20, 21, 54, 55, 52, 53, 66, 67, 64, 65, 58, 59, 56, 57, 74, 75, 72, 73, 82, 83, 80, 81, 94, 95, 92, 93, 78, 79, 76, 77, 118, 119, 116, 117, 86, 87
OFFSET
0,3
COMMENTS
The "fourth shifted power" of permutation A268718.
FORMULA
a(0) = 0, and for n >= 1, a(n) = 1 + A268824(A268718(n)-1).
PROG
(Scheme) (define (A268826 n) (if (zero? n) n (+ 1 (A268824 (+ -1 (A268718 n))))))
CROSSREFS
Inverse: A268825.
Row 4 of array A268830.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved
Permutation of nonnegative integers: a(0) = 0, a(n) = A268717(1+A268827(n-1)).
+10
6
0, 1, 3, 2, 6, 7, 5, 4, 13, 12, 11, 10, 15, 14, 31, 30, 27, 26, 9, 8, 25, 24, 55, 54, 51, 50, 17, 16, 49, 48, 29, 28, 21, 20, 19, 18, 23, 22, 103, 102, 99, 98, 33, 32, 97, 96, 45, 44, 37, 36, 35, 34, 39, 38, 53, 52, 61, 60, 59, 58, 63, 62, 47, 46, 43, 42, 57, 56, 41, 40, 199, 198, 195, 194, 65, 64, 193, 192, 77
OFFSET
0,3
COMMENTS
The sixth "shifted power" of A268717.
FORMULA
a(0) = 0, for n >= 1, a(n) = A268717(1+A268827(n-1)).
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]]]; A268823[n_]:= If[n<2, n, A268717[1 + A268717[1 + A268717[n - 2]]]]; A268825[n_]:=If[n<1, 0, A268717[1 + A268823[n - 1]]]; A268827[n_]:=If[n<1, 0, A268717[1 + A268825[n - 1]]]; A268831[n_]:=If[n<1, 0, A268717[1 + A268827[n - 1]]]; Table[A268831[n], {n, 0, 100}] (* Indranil Ghosh, Apr 03 2017 *)
PROG
(Scheme) (define (A268831 n) (if (zero? n) n (A268717 (+ 1 (A268827 (- 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)));
A268823(n) = if(n<2, n, A268717(1 + A268717(1 + A268717(n - 2))));
A268825(n) = if(n<1, 0, A268717(1+A268823(n - 1)));
A268827(n) = if(n<1, 0, A268717(1+A268825(n - 1)));
for(n=0, 100, print1(if(n<1, 0, A268717(1+A268827(n - 1))), ", ")) \\ Indranil Ghosh, Apr 03 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 A268823(n): return A268717(1 + A268717(1 + A268717(n - 2))) if n>1 else n
def A268825(n): return A268717(1 + A268823(n - 1)) if n>0 else 0
def A268827(n): return A268717(1 + A268825(n - 1)) if n>0 else 0
def a(n): return A268717(1 + A268827(n - 1)) if n>0 else 0
print([a(n) for n in range(101)]) # Indranil Ghosh, Apr 03 2017
CROSSREFS
Inverse: A268832.
Row 6 of A268820.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Feb 14 2016
STATUS
approved

Search completed in 0.006 seconds