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

A281149 Elias gamma code (EGC) for n.

Original entry on oeis.org

1, 100, 101, 11000, 11001, 11010, 11011, 1110000, 1110001, 1110010, 1110011, 1110100, 1110101, 1110110, 1110111, 111100000, 111100001, 111100010, 111100011, 111100100, 111100101, 111100110, 111100111, 111101000, 111101001, 111101010, 111101011, 111101100, 111101101, 111101110
Offset: 1

Views

Author

Indranil Ghosh, Jan 16 2017

Keywords

Comments

This sequence is the binary equivalent of A171885 for n>=1 and is also mentioned in the example section of the same.
The number of bits of a(n) is equal to A129972(n).
Unary(n) = A105279(n-1).

Examples

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

Crossrefs

Cf. A105279 (unary code for n), A129972, A171885.

Programs

  • Python
    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, it is stored in 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 unary and the second part is stored in binary using floor(log_2 n) bits. Now the first and the second parts are concatenated to give the answer.

A010097 Prefix (or Levenshtein) codes for natural numbers.

Original entry on oeis.org

0, 2, 12, 13, 112, 113, 114, 115, 232, 233, 234, 235, 236, 237, 238, 239, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 7712, 7713, 7714, 7715
Offset: 0

Views

Author

Keywords

References

  • D. E. Knuth, "Supernatural Numbers", in D. A. Klarner, editor, The Mathematical Gardner. Prindle, Weber and Schmidt, Boston, 1981, pp. 310-325.
  • D. E. Knuth, Selected Papers on Fun and Games, CSLI, 2011.
  • R. E. Krichevsky, Szhatie i poisk informatsii (Compressing and searching for information), Moscow, 1988, ISBN 5-256-00325-9.

Crossrefs

Knuth articles also give A000918 and A171885.

Programs

  • PARI
    apply( {A010097(n)=if(n, n+2^(n=exponent(n))*((n=A010097(n))+2<M. F. Hasler, Oct 24 2024
  • Python
    def encode(n):
        if n == 0: return "0"
        c, C = "", 1
        while n > 0:
            b = bin(n)[3:]
            c = b + c
            if (m := len(b)) > 0: C += 1
            n = m
        c = "1" * C + "0" + c
        return c
    a = lambda n: int(encode(n),2) # DarĂ­o Clavijo, Aug 23 2024
    

Formula

The code for n is found as follows: from right to left, the truncated (without the leading 1) binary representations of n, floor(log_2(n)), floor(log_2(floor(log_2(n)))), etc., are written as long as they consist of at least one bit; then we write a 0 followed by log*(n) 1's.

Extensions

Offset corrected by Matthew House, Aug 15 2016

A281223 The decimal representation of the Elias omega code for n (A281193(n)).

Original entry on oeis.org

0, 4, 6, 40, 42, 44, 46, 112, 114, 116, 118, 120, 122, 124, 126, 1312, 1314, 1316, 1318, 1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1340, 1342, 2752, 2754, 2756, 2758, 2760, 2762, 2764, 2766, 2768, 2770, 2772, 2774, 2776, 2778, 2780, 2782, 2784, 2786, 2788, 2790
Offset: 1

Views

Author

Indranil Ghosh, Jan 18 2017

Keywords

Examples

			For n = 6, the Elias omega code for 6 is '101100' which is 44 in decimal. So, a(6) = 44.
		

Crossrefs

Cf. A281193, A171885 (Decimal representation of the Elias gamma code for n).

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",2)

A281225 The decimal representation of the Elias delta code for n (A281150(n)).

Original entry on oeis.org

1, 8, 9, 20, 21, 22, 23, 192, 193, 194, 195, 196, 197, 198, 199, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857
Offset: 1

Views

Author

Indranil Ghosh, Jan 18 2017

Keywords

Examples

			For n = 6, The Elias delta code for 6 is "10110" which is 22 in decimal. So, a(6) = 22.
		

Crossrefs

Cf. A171885 (Decimal representation of the Elias gamma code for n), A281150, A281223.

Programs

  • Python
    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)
    				

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