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-5 of 5 results.

A281150 Elias delta code for n.

Original entry on oeis.org

1, 1000, 1001, 10100, 10101, 10110, 10111, 11000000, 11000001, 11000010, 11000011, 11000100, 11000101, 11000110, 11000111, 110010000, 110010001, 110010010, 110010011, 110010100, 110010101, 110010110, 110010111, 110011000, 110011001, 110011010
Offset: 1

Views

Author

Indranil Ghosh, Jan 16 2017

Keywords

Comments

The number of bits in a(n) is equal to A140341(n).
a(n) is the prefix-free encoding of n-1 defined on pages 180-181 of Shallit (2008). - N. J. A. Sloane, Mar 18 2019

Examples

			For n = 9, the first part is "11000" and the second part is "001". So a(9) = 11000001.
		

References

  • Shallit, Jeffrey. A second course in formal languages and automata theory. Cambridge University Press, 2008. See E(m) on page 181. - N. J. A. Sloane, Mar 18 2019

Crossrefs

Unary(n) = A105279(n-1).

Programs

  • Python
    import math
    def unary(n):
        return "1"*(n-1)+"0"
    def elias_gamma(n):
        if n==1:
            return "1"
        k=int(math.log(n, 2))
        fp=unary(1+k)    #fp is the first part
        sp=n-2**(k)      #sp is the second part
        nb=k             #nb is the number of bits used to store sp in binary
        sp=bin(sp)[2:]
        if len(sp)
    				

Formula

For a given integer n, a(n) is composed of two parts. The first part equals 1+floor(log_2 n) and the second part equals n-2^(floor(log_2 n)). The first part is stored in Elias Gamma Code and the second part is stored in a binary using floor(log_2 n) bits. The first and the second parts are concatenated to give a(n).

A129972 a(n) = 2*floor(log_2(n)) + 1.

Original entry on oeis.org

1, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
Offset: 1

Views

Author

Benoit Cloitre, Jun 13 2007

Keywords

Comments

The number of bits needed to write n using Elias gamma coding. - Charles R Greathouse IV, Mar 21 2012
Consists of the n-th odd number (A005408(n) = 2n+1) repeated 2^(n-1) times (since a(n) = a(n-1) except when a(n) > a(n-1) which happens for n a power of 2). - Jonathan Vos Post, Jun 17 2007

Crossrefs

Cf. A005408.
Cf. A281149 (See the comment section by Charles R Greathouse IV, of this sequence (A129972) ). - Indranil Ghosh, Jan 17 2017

Programs

Formula

a(n) = Sum_{k=1..n} (-1)^(k-1)*floor(n/k)*mu(k).

A281193 Elias's omega code for n.

Original entry on oeis.org

0, 100, 110, 101000, 101010, 101100, 101110, 1110000, 1110010, 1110100, 1110110, 1111000, 1111010, 1111100, 1111110, 10100100000, 10100100010, 10100100100, 10100100110, 10100101000, 10100101010, 10100101100, 10100101110, 10100110000, 10100110010, 10100110100
Offset: 1

Views

Author

Indranil Ghosh, Jan 17 2017

Keywords

Comments

The idea of the Elias omega code is similar to that of the Elias delta code (A281150), except that the length of the codeword in the omega code is recursively encoded.
The number of bits in a(n) is equal to A072464(n).

Crossrefs

Programs

  • Python
    def E(n):
        s=""
        if n==1:
            return "0"
        else:
            b=(bin(n)[2:])
            s+=E(len(b)-1)+b
        return s
    def elias_omega(n):
        return int(E(n)[1:]+"0")

A281551 Prime numbers p such that the decimal representation of its Elias gamma code is also a prime.

Original entry on oeis.org

3, 23, 41, 47, 59, 89, 101, 149, 179, 227, 317, 347, 353, 383, 389, 479, 503, 599, 821, 887, 929, 977, 1019, 1109, 1229, 1283, 1319, 1511, 1571, 1619, 1667, 1709, 1733, 1787, 1847, 1889, 1907, 1913, 1931, 2207, 2309, 2333, 2357, 2399, 2417, 2459, 2609, 2753, 2789, 2909, 2963, 2999, 3203, 3257, 3299
Offset: 1

Views

Author

Indranil Ghosh, Jan 24 2017

Keywords

Examples

			59 is in the sequence because the decimal representation of its Elias gamma code is 2011 and both 59 and 2011 are prime numbers.
		

Crossrefs

Cf. A000040, A171885 (decimal representation of Elias gamma code), A281149, A281316.

Programs

  • Python
    import math
    from sympy import isprime
    def unary(n):
        return "1"*(n-1)+"0"
    def elias_gamma(n):
        if n ==1:
            return "1"
        k=int(math.log(n,2))
        fp=unary(1+k)    #fp is the first part
        sp=n-2**(k)      #sp is the second part
        nb=k             #nb is the number of bits used to store sp in binary
        sp=bin(sp)[2:]
        if len(sp)
    				

A281552 Write n in the Elias gamma code and sum the positions where there is a '1' followed immediately to the right by a '0', counting the leftmost digit as position 1.

Original entry on oeis.org

0, 1, 1, 2, 2, 6, 2, 3, 3, 9, 3, 8, 8, 9, 3, 4, 4, 12, 4, 11, 11, 12, 4, 10, 10, 18, 10, 11, 11, 12, 4, 5, 5, 15, 5, 14, 14, 15, 5, 13, 13, 23, 13, 14, 14, 15, 5, 12, 12, 22, 12, 21, 21, 22, 12, 13, 13, 23, 13, 14, 14, 15, 5, 6, 6, 18, 6, 17, 17, 18, 6, 16, 16, 28, 16, 17, 17, 18, 6
Offset: 1

Views

Author

Indranil Ghosh, Jan 24 2017

Keywords

Examples

			For n = 6 , the Elias gamma code for n is '11010'. In '11010', the positions of '1' followed immediately to the right by '0' counting from left are 2 and 4. So, a(6) = 2 + 4 = 6.
For n = 10, the Elias gamma code for n is '1110010'. In '1110010', the positions of '1' followed immediately to the right by '0' counting from left are 3 and 6. So, a(10) = 3 + 6 = 9.
		

Crossrefs

Programs

  • Python
    def a(n):
        x= A281149(n)
        s=0
        for i in range(1,len(x)):
            if x[i-1]=="1" and x[i]=="0":
                s+=i
        return s

Formula

a(n) = A049501(A171885(n)) for n > = 1.
Showing 1-5 of 5 results.