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.

Showing 1-2 of 2 results.

A336956 For any number n whose set of nonzero decimal digits is { d_0, ..., d_k } (with d_0 < ... < d_k), a(n) is obtained by replacing in the decimal representation of n each nonzero digit d_m by d_{k-m} for m = 0..k.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 41, 51, 61, 71, 81, 91, 20, 12, 22, 32, 42, 52, 62, 72, 82, 92, 30, 13, 23, 33, 43, 53, 63, 73, 83, 93, 40, 14, 24, 34, 44, 54, 64, 74, 84, 94, 50, 15, 25, 35, 45, 55, 65, 75, 85, 95, 60, 16, 26, 36, 46, 56, 66, 76
Offset: 0

Views

Author

Rémy Sigrist, Aug 09 2020

Keywords

Comments

This sequence is a self-inverse permutation of nonnegative integers.
This sequence first differs from A321474 for n = 112: a(112) = 221 whereas A321474(112) = 211.
This sequence has similarities with A166166; here we consider nonzero decimal digits, there binary run-lengths.

Examples

			For n = 10251:
- the set of nonzero digits is { 1, 2, 5},
- so we replace each digit 1, 2, 5 respectively by 5, 2, 1,
- and a(10251) = 50215.
		

Crossrefs

Programs

  • PARI
    a(n, base=10) = { my (d=digits(n, base), s=Set(select(sign, d))); fromdigits(apply (t -> if (t, s[#s+1-setsearch (s,t)], 0), d), base) }

Formula

a(n) = n iff n = 0 or n belongs to A125289.

A166404 Self-inverse permutation of natural numbers obtained by exchanging the run lengths of adjacent runs of ones and zeros in the binary expansion of n, starting from the most significant run of 1's. (See the example lines).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Oct 20 2009

Keywords

Examples

			68 in binary is 1000100, so it consists of runs of 1, 3, 1 and 2 bits of the same value (alternatively 1 or 0) counted from the most significant end. Swapping these (the first with the second, the third with the fourth, etc.) gives the run lengths of [3,1,2,1], and the reconstructed binary string looks now as 1110110, which is 118 in binary. Thus a(68)=118.
Likewise, 67 in binary is 1000011, so it consists of runs of 1, 4 and 2 counted from the most significant end. Now we can swap just the first and second of these runs, with the remaining third run staying as it is, so we get run lengths of [4,1,2], and the reconstructed binary string looks now as 1111011, which is 123 in binary. Thus a(67)=123.
		

Crossrefs

Programs

  • Python
    def a(n):
        if n==0: return 0
        x=bin(n)[2:]
        r=[]
        s=1
        p=""
        for i in range(1, len(x)):
            if x[i - 1]==x[i]: s+=1
            else:
                r+=[s, ]
                s=1
        l=r+[s]
        L=[]
        if len(l)%2==0:
            for i in range(0, len(l), 2): L+=[l[i + 1], l[i]]
        else:
            b=l[-1]
            for i in range(0, len(l) - 1, 2): L+=[l[i + 1], l[i]]
            L+=[b, ]
        for i in range(len(L)):
            if i%2==0: p+='1'*L[i]
            else: p+='0'*L[i]
        return int(p, 2)
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 12 2017
Showing 1-2 of 2 results.