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.

Previous Showing 11-20 of 29 results. Next

A163327 Self-inverse permutation of integers: swap the odd- and even-positioned digits in the ternary expansion of n, then convert back to decimal.

Original entry on oeis.org

0, 3, 6, 1, 4, 7, 2, 5, 8, 27, 30, 33, 28, 31, 34, 29, 32, 35, 54, 57, 60, 55, 58, 61, 56, 59, 62, 9, 12, 15, 10, 13, 16, 11, 14, 17, 36, 39, 42, 37, 40, 43, 38, 41, 44, 63, 66, 69, 64, 67, 70, 65, 68, 71, 18, 21, 24, 19, 22, 25, 20, 23, 26, 45, 48, 51, 46, 49, 52, 47, 50, 53
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			11 in ternary base (A007089) is written as '(000...)102' (... + 0*27 + 1*9 + 0*3 + 2), which results '1020' = 1*27 + 0*9 + 2*3 + 0 = 33, when the odd- and even-positioned digits are swapped, thus a(11) = 33.
		

Crossrefs

Programs

  • Python
    from sympy.ntheory import digits
    def a(n):
        d = digits(n, 3)[1:]
        return sum(3**(i+(1-2*(i&1)))*di for i, di in enumerate(d[::-1]))
    print([a(n) for n in range(72)]) # Michael S. Branicky, Aug 05 2022
  • Scheme
    (define (A163327 n) (+ (A037314 (A163326 n)) (* 3 (A037314 (A163325 n)))))
    

Formula

a(n) = A037314(A163326(n)) + 3*A037314(A163325(n))

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A163233 Two-dimensional Binary Reflected Gray Code: a(i,j) = bits of binary expansion of A003188(i) interleaved with that of A003188(j).

Original entry on oeis.org

0, 1, 2, 5, 3, 10, 4, 7, 11, 8, 20, 6, 15, 9, 40, 21, 22, 14, 13, 41, 42, 17, 23, 30, 12, 45, 43, 34, 16, 19, 31, 28, 44, 47, 35, 32, 80, 18, 27, 29, 60, 46, 39, 33, 160, 81, 82, 26, 25, 61, 62, 38, 37, 161, 162, 85, 83, 90, 24, 57, 63, 54, 36, 165, 163, 170, 84, 87, 91
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Comments

The top left 8 X 8 corner of the array is
+0 +1 +5 +4 20 21 17 16
+2 +3 +7 +6 22 23 19 18
10 11 15 14 30 31 27 26
+8 +9 13 12 28 29 25 24
40 41 45 44 60 61 57 56
42 43 47 46 62 63 59 58
34 35 39 38 54 55 51 50
32 33 37 36 52 53 49 48
By taking the top left 2 X 2 corner, 2 X 4 rectangle ((0,1,5,4),(2,3,7,6)) or 4 X 4 corner one obtains Karnaugh map templates for 2, 3 or 4 variables respectively (although not the standard ones usually given in the textbooks).

Crossrefs

Inverse: A163234. a(n) = A057300(A163235(n)). Transpose: A163235. Row sums: A163242. Cf. A054238, A147995.

Programs

  • Mathematica
    Table[Function[k, FromDigits[#, 2] &@ Apply[Function[{a, b}, Riffle @@ Map[PadLeft[#, Max[Length /@ {a, b}]] &, {a, b}]], Map[IntegerDigits[#, 2] &@ BitXor[#, Floor[#/2]] &, {k, j}]]][i - j], {i, 0, 11}, {j, i, 0, -1}] // Flatten (* Michael De Vlieger, Jun 25 2017 *)
  • Python
    def a000695(n):
        n=bin(n)[2:]
        x=len(n)
        return sum([int(n[i])*4**(x - 1 - i) for i in range(x)])
    def a003188(n): return n^(n>>1)
    def a(n, k): return a000695(a003188(n)) + 2*a000695(a003188(k))
    for n in range(21): print([a(n - k, k) for k in range(n + 1)]) # Indranil Ghosh, Jun 25 2017
  • Scheme
    (define (A163233bi x y) (+ (A000695 (A003188 x)) (* 2 (A000695 (A003188 y)))))
    (define (A163233 n) (A163233bi (A025581 n) (A002262 n)))
    

Formula

a(x,y) = A000695(A003188(x)) + 2*A000695(A003188(y)).

A163235 Two-dimensional Binary Reflected Gray Code, transposed version: a(i,j) = bits of binary expansion of A003188(j) interleaved with that of A003188(i).

Original entry on oeis.org

0, 2, 1, 10, 3, 5, 8, 11, 7, 4, 40, 9, 15, 6, 20, 42, 41, 13, 14, 22, 21, 34, 43, 45, 12, 30, 23, 17, 32, 35, 47, 44, 28, 31, 19, 16, 160, 33, 39, 46, 60, 29, 27, 18, 80, 162, 161, 37, 38, 62, 61, 25, 26, 82, 81, 170, 163, 165, 36, 54, 63, 57, 24, 90, 83, 85, 168, 171, 167
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Comments

The top left 8x8 corner of this array
+0 +2 10 +8 40 42 34 32
+1 +3 11 +9 41 43 35 33
+5 +7 15 13 45 47 39 37
+4 +6 14 12 44 46 38 36
20 22 30 28 60 62 54 52
21 23 31 29 61 63 55 53
17 19 27 25 57 59 51 49
16 18 26 24 56 58 50 48
corresponds with Adamson's "H-bond codon-anticodon magic square" (see page 287 in Pickover's book):
CCC CCU CUU CUC UUC UUU UCU UCC
CCA CCG CUG CUA UUA UUG UCG UCA
CAA CAG CGG CGA UGA UGG UAG UAA
CAC CAU CGU CGC UGC UGU UAU UAC
AAC AAU AGU AGC GGC GGU GAU GAC
AAA AAG AGG AGA GGA GGG GAG GAA
ACA ACG AUG AUA GUA GUG GCG GCA
ACC ACU AUU AUC GUC GUU GCU GCC
when the base-triples are interpreted as quaternary (base-4) numbers, with the following rules: C = 0, A = 1, U = 2, G = 3.

References

  • Clifford A. Pickover, The Zen of Magic Squares, Circles, and Stars: An Exhibition of Surprising Structures across Dimensions, Princeton University Press, 2002, pp. 285-289.

Crossrefs

Inverse: A163236. a(n) = A057300(A163233(n)). Transpose: A163233. Row sums: A163242. Cf. A054238, A147995.

Programs

  • Mathematica
    Table[Function[k, FromDigits[#, 2] &@Apply[Function[{a, b}, Riffle @@ Map[PadLeft[#, Max[Length /@ {a, b}]] &, {a, b}]], Map[IntegerDigits[#, 2] &@ BitXor[#, Floor[#/2]] &, {k, j}]]][i - j], {i, 0, 11}, {j, 0, i}] // Flatten (* Michael De Vlieger, Jun 25 2017 *)
  • Python
    def a000695(n):
        n=bin(n)[2:]
        x=len(n)
        return sum(int(n[i])*4**(x - 1 - i) for i in range(x))
    def a003188(n): return n^(n>>1)
    def a(n, k): return a000695(a003188(n)) + 2*a000695(a003188(k))
    for n in range(21): print([a(k, n - k) for k in range(n + 1)]) # Indranil Ghosh, Jun 25 2017
  • Scheme
    (define (A163235 n) (A163233bi (A002262 n) (A025581 n)))
    

A126006 Involution of nonnegative integers: Swap the positions of digits q0 <-> q1, q2 <-> q3, q4 <-> q5, etc. in the base-4 expansion of n (where n = ... + q4*256 + q3*64 + q2*16 + q1*4 + q0).

Original entry on oeis.org

0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 64, 68, 72, 76, 65, 69, 73, 77, 66, 70, 74, 78, 67, 71, 75, 79, 128, 132, 136, 140, 129, 133, 137, 141, 130, 134, 138, 142, 131, 135, 139, 143, 192, 196, 200, 204, 193, 197, 201, 205, 194, 198, 202, 206, 195
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Examples

			29 = 0*64 + 1*16 + 3*4 + 1, i.e., 131 in quaternary and when digits are swapped in pairs, results 1013 in quaternary (1*64 + 0*16 + 1*4 + 3 = 71 in decimal), thus a(29)=71.
		

Crossrefs

Cf. A126007. A057300 is the analogous permutation based on swapping the binary digits of n.
Cf. A004442.

Programs

  • C
    #include 
    uint32_t a(uint32_t n) { return ((n & 0x33333333) << 2) | ((n & 0xcccccccc) >> 2); } /* Falk Hüffner, Jan 23 2022 */
    
  • PARI
    a(n) = my(d=Vecrev(digits(n, 4))); if (#d % 2, d = concat(d, 0)); fromdigits(Vecrev(vector(#d, i, d[i+(-1)^(i-1)])), 4); \\ Michel Marcus, Jan 23 2022
  • Scheme
    (define (A126006 n) (let loop ((n n) (s 0) (p 1)) (cond ((zero? n) s) (else (loop (floor->exact (/ n 16)) (+ s (* p (+ (* 4 (modulo n 4)) (modulo (floor->exact (/ n 4)) 4)))) (* p 16))))))
    

A302845 Permutation of nonnegative integers: a(n) = A163355(A064707(n)).

Original entry on oeis.org

0, 1, 3, 2, 15, 14, 12, 13, 5, 6, 4, 7, 10, 9, 11, 8, 21, 20, 22, 23, 16, 19, 17, 18, 26, 27, 25, 24, 31, 28, 30, 29, 63, 62, 60, 61, 48, 49, 51, 50, 58, 57, 59, 56, 53, 54, 52, 55, 42, 43, 41, 40, 47, 44, 46, 45, 37, 36, 38, 39, 32, 35, 33, 34, 255, 254, 252, 253, 240, 241, 243, 242, 250, 249, 251, 248, 245, 246, 244
Offset: 0

Views

Author

Antti Karttunen, Apr 14 2018

Keywords

Crossrefs

Programs

Formula

a(n) = A163355(A064707(n)).
a(n) = A302843(A006068(n)).

A106485 CGT-tree negating involution of nonnegative integers.

Original entry on oeis.org

0, 2, 1, 3, 32, 34, 33, 35, 16, 18, 17, 19, 48, 50, 49, 51, 8, 10, 9, 11, 40, 42, 41, 43, 24, 26, 25, 27, 56, 58, 57, 59, 4, 6, 5, 7, 36, 38, 37, 39, 20, 22, 21, 23, 52, 54, 53, 55, 12, 14, 13, 15, 44, 46, 45, 47, 28, 30, 29, 31, 60, 62, 61, 63, 128, 130, 129, 131, 160, 162
Offset: 0

Views

Author

Antti Karttunen, May 21 2005

Keywords

Comments

This involution negates game trees used in the combinatorial game theory, when they are encoded in the way explained in A106486.
Cycles are confined into ranges [a(n),a(n+1)[, where a(0)=0 and a(n+1)=2^(2*a(n)), i.e. the ranges are [0,0], [1,3], [4,255], [256,(2^512)-1], ...

Crossrefs

A057300 is a "shallow" version which just swaps the left and right options of the game tree, but does not reflect the subtrees themselves. Cf. A106486-A106487.

Programs

  • Scheme
    (define (A106485 n) (let loop ((n n) (i 0) (s 0)) (cond ((zero? n) s) ((odd? n) (loop (/ (- n 1) 2) (1+ i) (+ s (if (even? i) (expt 2 (+ 1 (* 2 (A106485 (/ i 2))))) (expt 2 (* 2 (A106485 (/ (- i 1) 2)))))))) (else (loop (/ n 2) (1+ i) s)))))

A163485 Permutation of integers used for constructing A147995 and A163545.

Original entry on oeis.org

0, 3, 1, 2, 14, 15, 13, 12, 6, 7, 5, 4, 8, 11, 9, 10, 58, 57, 59, 56, 62, 63, 61, 60, 54, 55, 53, 52, 50, 49, 51, 48, 26, 25, 27, 24, 30, 31, 29, 28, 22, 23, 21, 20, 18, 17, 19, 16, 32, 35, 33, 34, 46, 47, 45, 44, 38, 39, 37, 36, 40, 43, 41, 42, 234, 233, 235, 232, 228, 229
Offset: 0

Views

Author

Antti Karttunen, Aug 01 2009

Keywords

Crossrefs

Inverse: A163486. This permutation can be used to construct array A147995 and its transpose A163545. See A163355 for a bit similarly defined recursive permutation.

A302843 Permutation of nonnegative integers: a(n) = A163355(A006068(n)).

Original entry on oeis.org

0, 1, 2, 3, 12, 13, 14, 15, 10, 9, 8, 11, 4, 7, 6, 5, 26, 27, 24, 25, 30, 29, 28, 31, 16, 19, 18, 17, 22, 23, 20, 21, 42, 43, 40, 41, 46, 45, 44, 47, 32, 35, 34, 33, 38, 39, 36, 37, 58, 57, 56, 59, 52, 55, 54, 53, 48, 49, 50, 51, 60, 61, 62, 63, 192, 193, 194, 195, 204, 205, 206, 207, 202, 201, 200, 203, 196, 199, 198, 197, 218, 219, 216, 217, 222
Offset: 0

Views

Author

Antti Karttunen, Apr 14 2018

Keywords

Crossrefs

Cf. A302844 (inverse).

Programs

  • PARI
    A006068(n)= { my(s=1, ns); while(1, ns = n >> s; if(0==ns, break()); n = bitxor(n, ns); s <<= 1; ); return (n); } \\ From A006068
    A057300(n) = { my(t=1, s=0); while(n>0,  if(1==(n%4),n++,if(2==(n%4),n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); };
    A163355(n) = if(!n,n,my(i = (#binary(n)-1)\2, f = 4^i, d = (n\f)%4, r = (n%f)); if(((1==d)&&!(i%2))||((2==d)&&(i%2)), f+A163355(A057300(r)), if(3==d,f+f+A163355(A057300(r)), (3*f)+A163355(f-1-r))));
    A302843(n) = A163355(A006068(n));

Formula

a(n) = A163355(A006068(n)).
a(n) = A302845(A003188(n)).

A302844 Permutation of nonnegative integers: a(n) = A003188(A163356(n)).

Original entry on oeis.org

0, 1, 2, 3, 12, 15, 14, 13, 10, 9, 8, 11, 4, 5, 6, 7, 24, 27, 26, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 21, 20, 23, 40, 43, 42, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 37, 36, 39, 56, 57, 58, 59, 52, 55, 54, 53, 50, 49, 48, 51, 60, 61, 62, 63, 192, 195, 194, 193, 198, 199, 196, 197, 202, 203, 200, 201, 206, 205
Offset: 0

Views

Author

Antti Karttunen, Apr 14 2018

Keywords

Comments

When A207901, which is a multiplicative walk permutation, is composed from the right with this permutation, the result is A302781, another multiplicative walk permutation.

Crossrefs

Programs

Formula

a(n) = A003188(A163356(n)).
a(n) = A006068(A302846(n)).

A054240 Bit-interleaved number addition table; like binary addition but carries shift 2 instead of 1; addition base sqrt(2).

Original entry on oeis.org

0, 1, 1, 2, 4, 2, 3, 3, 3, 3, 4, 6, 8, 6, 4, 5, 5, 9, 9, 5, 5, 6, 16, 6, 12, 6, 16, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 18, 12, 18, 16, 18, 12, 18, 8, 9, 9, 13, 13, 17, 17, 13, 13, 9, 9, 10, 12, 10, 24, 18, 20, 18, 24, 10, 12, 10, 11, 11, 11, 11, 19, 19, 19, 19, 11, 11, 11, 11, 12, 14, 32, 14
Offset: 0

Views

Author

Marc LeBrun, Feb 07 2000

Keywords

Examples

			T(3,1)=6 because (0*2 + 1*sqrt(2) + 1*1) + (0*2 + 0*sqrt(2) + 1*1) = (1*2 + 1*sqrt(2) + 0*1) (i.e., base sqrt(2) addition).
		

Crossrefs

Cf. A000695, A054239, A057300, A062880, A352909 (pairs (i,j) such that A(i,j) = i+j).
Cf. A201651 (triangle read by rows).

Programs

  • Haskell
    import Data.Bits (xor, (.&.), shift)
    a054240 :: Integer -> Integer -> Integer
    a054240 x 0 = x
    a054240 x y = a054240 (x `xor` y) (shift (x .&. y) 2)
    a054240_adiag n =  map (\k -> a054240 (n - k) k) [0..n]
    a054240_square = map a054240_adiag [0..]
    -- Reinhard Zumkeller, Dec 03 2011

Formula

From Peter Munn, Dec 10 2019: (Start)
A(m,0) = A(0,m) = m.
A(n,k) = A(k,n).
A(n, A(m,k)) = A(A(n,m), k).
A(m,m) = 4*m.
A(2*n, 2*k) = 2*A(n,k).
A(A000695(n), A000695(k)) = A000695(n+k).
A(A000695(n), 2*A000695(k)) = A000695(n) + 2*A000695(k).
A(A000695(n) + 2*A000695(m), k) = A(A000695(n), k) + A(2*A000695(m), k) - k.
A(A057300(n), A057300(k)) = A057300(A(n,k)).
(End)
Previous Showing 11-20 of 29 results. Next