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 21-29 of 29 results.

A126007 Involution of nonnegative integers: Keep the least significant quaternary digit q0 of n fixed, but swap the positions of digits q1 <-> q2, q3 <-> q4, ..., 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, 1, 2, 3, 16, 17, 18, 19, 32, 33, 34, 35, 48, 49, 50, 51, 4, 5, 6, 7, 20, 21, 22, 23, 36, 37, 38, 39, 52, 53, 54, 55, 8, 9, 10, 11, 24, 25, 26, 27, 40, 41, 42, 43, 56, 57, 58, 59, 12, 13, 14, 15, 28, 29, 30, 31, 44, 45, 46, 47, 60, 61, 62, 63, 256, 257, 258, 259, 272
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Crossrefs

Programs

  • C
    #include 
    uint32_t a(uint32_t n) { return ((n & 0xcccccccc) << 2) | ((n & 0x33333330) >> 2) | (n & 3); } /* Falk Hüffner, Jan 23 2022 */
    
  • PARI
    f(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); \\ A126006
    a(n) = (n % 4) + 4*f(n\4); \\ Michel Marcus, Jan 23 2022

Formula

a(n) = (n mod 4) + 4*A126006(floor(n/4)).
a(n) = A057300(A126008(n)) = A126008(A057300(n)).

A163234 Inverse permutation to A163233.

Original entry on oeis.org

0, 1, 2, 4, 6, 3, 11, 7, 9, 13, 5, 8, 24, 18, 17, 12, 28, 21, 37, 29, 10, 15, 16, 22, 58, 48, 47, 38, 31, 39, 23, 30, 35, 43, 27, 34, 62, 52, 51, 42, 14, 19, 20, 26, 32, 25, 41, 33, 112, 98, 97, 84, 73, 85, 61, 72, 70, 59, 83, 71, 40, 49, 50, 60, 120, 105, 137, 121, 78
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Crossrefs

Inverse: A163233. a(n) = A163236(A057300(n)). Cf. A163236.

Programs

  • Python
    def A(x, y): return (((x + y)**2) + x + 3*y)//2
    def a006068(n):
        s=1
        while True:
            ns=n>>s
            if ns==0: break
            n=n^ns
            s<<=1
        return n
    def a059905(n): return sum([(n>>2*i&1)<Indranil Ghosh, Jun 25 2017
  • Scheme
    (define (A163234 n) (A001477bi (A006068 (A059905 n)) (A006068 (A059906 n))))
    (define (A001477bi x y) (/ (+ (expt (+ x y) 2) x (* 3 y)) 2))
    

Formula

a(n) = A001477bi(A006068(A059905(n)),A006068(A059906(n))), where A001477bi(x,y) = (((x+y)^2)+x+(3y))/2.

A163236 Inverse permutation to A163235.

Original entry on oeis.org

0, 2, 1, 4, 9, 5, 13, 8, 6, 11, 3, 7, 24, 17, 18, 12, 35, 27, 43, 34, 14, 20, 19, 26, 62, 51, 52, 42, 32, 41, 25, 33, 28, 37, 21, 29, 58, 47, 48, 38, 10, 16, 15, 22, 31, 23, 39, 30, 112, 97, 98, 84, 70, 83, 59, 71, 73, 61, 85, 72, 40, 50, 49, 60, 135, 119, 151, 134, 90
Offset: 0

Author

Antti Karttunen, Jul 29 2009

Keywords

Crossrefs

Inverse: A163235. a(n) = A163234(A057300(n)). Cf. A163234.

Programs

  • Python
    def A(x, y): return (((x + y)**2) + x + 3*y)//2
    def a006068(n):
        s=1
        while True:
            ns=n>>s
            if ns==0: break
            n=n^ns
            s<<=1
        return n
    def a059905(n): return sum([(n>>2*i&1)<Indranil Ghosh, Jun 25 2017
  • Scheme
    (define (A163236 n) (A001477bi (A006068 (A059906 n)) (A006068 (A059905 n))))
    (define (A001477bi x y) (/ (+ (expt (+ x y) 2) x (* 3 y)) 2))
    

Formula

a(n) = A001477bi(A006068(A059906(n)),A006068(A059905(n))), where A001477bi(x,y) = (((x+y)^2)+x+(3y))/2.

A302782 Inverse permutation to A302781.

Original entry on oeis.org

0, 1, 3, 15, 5, 2, 21, 14, 63, 6, 255, 12, 85, 20, 4, 341, 1023, 62, 4095, 10, 22, 254, 1365, 13, 5461, 86, 60, 16, 16383, 7, 65535, 340, 252, 1022, 26, 48, 21845, 4094, 84, 9, 87381, 23, 262143, 240, 58, 1366, 1048575, 342, 349525, 5460, 1020, 90, 1398101, 61, 250, 19, 4092, 16382, 4194303, 11, 16777215, 65534, 42
Offset: 1

Author

Antti Karttunen, Apr 14 2018

Keywords

Crossrefs

Cf. A302781 (inverse).

Programs

  • PARI
    up_to = 8192;
    v050376 = vector(up_to);
    ispow2(n) = (n && !bitand(n,n-1));
    i = 0; for(n=1,oo,if(ispow2(isprimepower(n)), i++; v050376[i] = n); if(i == up_to,break));
    A052331(n) = { my(s=0,e); while(n > 1, fordiv(n, d, if(((n/d)>1)&&ispow2(isprimepower(n/d)), e = vecsearch(v050376, n/d); if(!e, print("v050376 too short!"); return(1/0)); s += 2^(e-1); n = d; break))); (s); };
    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))));
    A302845(n) = A163355(A006068(A006068(n)));
    A302782(n) = A302845(A052331(n));

Formula

a(n) = A302845(A052331(n)).

A341288 Square array T(n, k), read by antidiagonals, n, k >= 0; T(n, k) = XOR_{u in B(n), v in B(k)} 2^(u XOR v) where XOR denotes the bitwise XOR operator and B(n) gives the exponents in expression for n as a sum of powers of 2.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 2, 2, 0, 0, 3, 1, 3, 0, 0, 4, 3, 3, 4, 0, 0, 5, 8, 0, 8, 5, 0, 0, 6, 10, 12, 12, 10, 6, 0, 0, 7, 9, 15, 1, 15, 9, 7, 0, 0, 8, 11, 15, 5, 5, 15, 11, 8, 0, 0, 9, 4, 12, 9, 0, 9, 12, 4, 9, 0, 0, 10, 6, 12, 13, 15, 15, 13, 12, 6, 10, 0
Offset: 0

Author

Rémy Sigrist, Feb 08 2021

Keywords

Comments

For any x >= 0, the function n -> T(n, 2^x) is a self-inverse permutation of the nonnegative integers.
The set of nonnegative integers equipped with T forms a commutative monoid; its invertible elements are the odious numbers (A000069).
Hence A000069 equipped with T forms a group.

Examples

			Array T(n, k) begins:
  n\k|  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
  ---+---------------------------------------------------------------
    0|  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    1|  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
    2|  0   2   1   3   8  10   9  11   4   6   5   7  12  14  13  15 -> A057300
    3|  0   3   3   0  12  15  15  12  12  15  15  12   0   3   3   0
    4|  0   4   8  12   1   5   9  13   2   6  10  14   3   7  11  15 -> A126006
    5|  0   5  10  15   5   0  15  10  10  15   0   5  15  10   5   0
    6|  0   6   9  15   9  15   0   6   6   0  15   9  15   9   6   0
    7|  0   7  11  12  13  10   6   1  14   9   5   2   3   4   8  15
    8|  0   8   4  12   2  10   6  14   1   9   5  13   3  11   7  15
    9|  0   9   6  15   6  15   0   9   9   0  15   6  15   6   9   0
   10|  0  10   5  15  10   0  15   5   5  15   0  10  15   5  10   0
   11|  0  11   7  12  14   5   9   2  13   6  10   1   3   8   4  15
   12|  0  12  12   0   3  15  15   3   3  15  15   3   0  12  12   0
   13|  0  13  14   3   7  10   9   4  11   6   5   8  12   1   2  15
   14|  0  14  13   3  11   5   6   8   7   9  10   4  12   2   1  15
   15|  0  15  15   0  15   0   0  15  15   0   0  15   0  15  15   0
                                                                     \
                                                                      v
                                                                    A010060
		

Crossrefs

Programs

  • PARI
    B(n) = { my (b=vector(hammingweight(n))); for (k=1, #b, n -= 2^(b[k] = valuation(n, 2))); b }
    T(n,k) = { my (nn=B(n), kk=B(k), v=0); for (i=1, #nn, for (j=1, #kk, v=bitxor(v, 2^bitxor(nn[i], kk[j])))); v }

Formula

T(n, k) = T(k, n) (T is commutative).
T(m, T(n, k)) = T(T(m, n), k) (T is associative).
T(n, 0) = 0 (0 is an absorbing element for T).
T(n, 1) = n (1 is the neutral element for T).
T(n, 2) = A057300(n).
T(n, 4) = A126006(n).
T(n, n) = A010060(n).
A010060(T(n, k)) = A010060(n) * A010060(k).

A341487 Second row of A341458.

Original entry on oeis.org

2, 1, 5, 6, 3, 4, 8, 7, 17, 18, 22, 21, 20, 19, 23, 24, 9, 10, 14, 13, 12, 11, 15, 16, 26, 25, 29, 30, 27, 28, 32, 31, 65, 66, 70, 69, 68, 67, 71, 72, 82, 81, 85, 86, 83, 84, 88, 87, 74, 73, 77, 78, 75, 76, 80, 79, 89, 90, 94, 93, 92, 91, 95, 96, 33, 34, 38
Offset: 1

Author

Rémy Sigrist, Feb 13 2021

Keywords

Comments

This sequence is a self-inverse permutation of the positive integers.
This sequence has similarities with A057300.

Examples

			a(7) = A341458(2, 7) = 8.
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

a(n) = A341458(2, n).

A361946 If the base-4 expansion of n starts with the digit 1, then replace 2's by 3's and vice versa; if it starts with the digit 2, then replace 1's by 3's and vice versa; if it starts with the digit 3, then replace 1's by 2's and vice versa; a(0) = 0.

Original entry on oeis.org

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

Author

Rémy Sigrist, Apr 01 2023

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.

Examples

			For n = 539:
- the base-4 expansion of 539 is "20123",
- it starts with the digit 2, so we replace 1's by 3's and vice versa,
- so the base-4 expansion of a(539) is "20321", and a(539) = 569.
		

Programs

  • PARI
    a(n) = { my (q = digits(n, 4), m = if (#q, [ [0,1,3,2], [0,3,2,1], [0,2,1,3] ][q[1]], [0,1,2,3])); fromdigits(apply (d -> m[1+d], q), 4); }

Formula

a(n) = A163241(n) when A122587(n) = 1.
a(n) = A048647(n) when A122587(n) = 2.
a(n) = A057300(n) when A122587(n) = 3.
a(n) = n iff n = d * A000695(k) for some d in {1, 2, 3} and some k >= 0.

A361947 If the rightmost nonzero digit in the base-4 expansion of n is the digit 1, then replace 2's by 3's and vice versa; if it is the digit 2, then replace 1's by 3's and vice versa; if it is the digit 3, then replace 1's by 2's and vice versa; a(0) = 0.

Original entry on oeis.org

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

Author

Rémy Sigrist, Apr 01 2023

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.

Examples

			For n = 539:
- the base-4 expansion of 539 is "20123",
- the rightmost nonzero digit is 3, so we replace 1's by 2's and vice versa,
- so the base-4 expansion of a(539) is "10213", and a(539) = 295.
		

Programs

  • PARI
    a(n) = { my (m = if (n, [ [0,1,3,2], [0,3,2,1], [0,2,1,3] ][(n / 4^valuation(n, 4)) % 4], [0,1,2,3])); fromdigits(apply (d -> m[1+d], digits(n, 4)), 4); }

Formula

a(n) = A163241(n) when A065882(n) = 1.
a(n) = A048647(n) when A065882(n) = 2.
a(n) = A057300(n) when A065882(n) = 3.
a(n) = n iff n = d * A000695(k) for some d in {1, 2, 3} and some k >= 0.

A057301 Binary counter with bit positions permuted in increasing length cycles: 0;2,1;5,3,4;9,6,7,8,...

Original entry on oeis.org

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

Author

Marc LeBrun, Aug 24 2000

Keywords

Comments

A permutation of the integers

Crossrefs

Previous Showing 21-29 of 29 results.