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.
%I A281149 #24 May 22 2025 10:21:45 %S A281149 1,100,101,11000,11001,11010,11011,1110000,1110001,1110010,1110011, %T A281149 1110100,1110101,1110110,1110111,111100000,111100001,111100010, %U A281149 111100011,111100100,111100101,111100110,111100111,111101000,111101001,111101010,111101011,111101100,111101101,111101110 %N A281149 Elias gamma code (EGC) for n. %C A281149 This sequence is the binary equivalent of A171885 for n>=1 and is also mentioned in the example section of the same. %C A281149 The number of bits of a(n) is equal to A129972(n). %C A281149 Unary(n) = A105279(n-1). %H A281149 Indranil Ghosh, <a href="/A281149/b281149.txt">Table of n, a(n) for n = 1..10000</a> %H A281149 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. %F A281149 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. %e A281149 For n = 9, first part is "1110" and the second part is "001". So, a(9) = 1110001. %o A281149 (Python) %o A281149 def unary(n): %o A281149 return "1"*(n-1)+"0" %o A281149 def elias_gamma(n): %o A281149 if n ==1: %o A281149 return "1" %o A281149 k=int(math.log(n,2)) %o A281149 fp=unary(1+k) #fp is the first part %o A281149 sp=n-2**(k) #sp is the second part %o A281149 nb=k #nb is the number of bits used to store sp in binary %o A281149 sp=bin(sp)[2:] %o A281149 if len(sp)<nb: %o A281149 sp=("0"*(nb-len(sp)))+sp %o A281149 return fp+sp %Y A281149 Cf. A105279 (unary code for n), A129972, A171885. %K A281149 nonn,base %O A281149 1,2 %A A281149 _Indranil Ghosh_, Jan 16 2017