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.

A380934 Elias delta encoding of n converted from base 2 to integer.

This page as a plain text file.
%I A380934 #43 Apr 30 2025 23:17:37
%S A380934 1,4,5,12,13,14,15,32,33,34,35,36,37,38,39,80,81,82,83,84,85,86,87,88,
%T A380934 89,90,91,92,93,94,95,192,193,194,195,196,197,198,199,200,201,202,203,
%U A380934 204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219
%N A380934 Elias delta encoding of n converted from base 2 to integer.
%C A380934 This is the Elias delta coding of n with leading zeros omited.
%H A380934 Wikipedia, <a href="https://en.wikipedia.org/wiki/Elias_delta_coding">Elias delta coding</a>
%e A380934 For n = 16 a(16) = 80 because:
%e A380934 16 = 10000_2 and
%e A380934 Strip leading bit of n = 0000_2.
%e A380934 16 is of bitsize 5.
%e A380934 Prepend 5-1 zeros and 5 as 101_2
%e A380934 0000101_2 + 0000_2 = 00001010000_2 = 80.
%t A380934 A380934[n_] := FromDigits[Join[IntegerDigits[BitLength[n], 2], Rest[IntegerDigits[n, 2]]], 2] (* _James C. McMahon_, Apr 30 2025 *)
%o A380934 (Python)
%o A380934 def a(n):
%o A380934     if n == 1: return 1
%o A380934     b = bin(n)[2:]
%o A380934     L = len(b)
%o A380934     g = '0' * (L - 1) + bin(L)[2:]
%o A380934     d = g + b[1:]
%o A380934     return int(d,2)
%o A380934 print([a(n) for n in range(1,60)])
%o A380934 (Python)
%o A380934 def A380934(n): return int(bin(n.bit_length())+bin(n)[3:],2) # _Chai Wah Wu_, Apr 21 2025
%Y A380934 Cf. A281150.
%K A380934 nonn,base
%O A380934 1,2
%A A380934 _DarĂ­o Clavijo_, Apr 21 2025