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.

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

This page as a plain text file.
%I A281225 #14 May 22 2025 10:21:45
%S A281225 1,8,9,20,21,22,23,192,193,194,195,196,197,198,199,400,401,402,403,
%T A281225 404,405,406,407,408,409,410,411,412,413,414,415,832,833,834,835,836,
%U A281225 837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857
%N A281225 The decimal representation of the Elias delta code for n (A281150(n)).
%H A281225 Indranil Ghosh, <a href="/A281225/b281225.txt">Table of n, a(n) for n = 1..10000</a>
%H A281225 J. Nelson Raja, P. Jaganathan and S. Domnic, <a href="http://dx.doi.org/10.17485/ijst/2015/v8i24/80242">A New Variable-Length Integer Code for Integer Representation and Its Application to Text Compression</a>, Indian Journal of Science and Technology, Vol 8(24), September 2015.
%e A281225 For n = 6, The Elias delta code for 6 is "10110" which is 22 in decimal. So, a(6) = 22.
%o A281225 (Python)
%o A281225 def unary(n):
%o A281225     return "1"*(n-1)+"0"
%o A281225 def elias_gamma(n):
%o A281225     if n==1:
%o A281225         return "1"
%o A281225     k=int(math.log(n, 2))
%o A281225     fp=unary(1+k)    #fp is the first part
%o A281225     sp=n-2**(k)      #sp is the second part
%o A281225     nb=k             #nb is the number of bits used to store sp in binary
%o A281225     sp=bin(sp)[2:]
%o A281225     if len(sp)<nb:
%o A281225         sp=("0"*(nb-len(sp)))+sp
%o A281225     return fp+sp
%o A281225 def elias_delta(n):
%o A281225     if n==1:
%o A281225         return "1"
%o A281225     k=int(math.log(n, 2))
%o A281225     fp=elias_gamma(1+k)#fp is the first part
%o A281225     sp=n-2**(k)        #sp is the second part
%o A281225     nb=k               #nb is the number of bits used to store sp in binary
%o A281225     sp=bin(sp)[2:]
%o A281225     if len(sp)<nb:
%o A281225         sp=("0"*(nb-len(sp)))+sp
%o A281225     return fp+sp
%o A281225 def a(n):
%o A281225     return int(elias_delta(n),2)
%Y A281225 Cf. A171885 (Decimal representation of the Elias gamma code for n), A281150, A281223.
%K A281225 nonn,base
%O A281225 1,2
%A A281225 _Indranil Ghosh_, Jan 18 2017