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.

Original entry on oeis.org

1, 4, 5, 12, 13, 14, 15, 32, 33, 34, 35, 36, 37, 38, 39, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219
Offset: 1

Views

Author

DarĂ­o Clavijo, Apr 21 2025

Keywords

Comments

This is the Elias delta coding of n with leading zeros omited.

Examples

			For n = 16 a(16) = 80 because:
16 = 10000_2 and
Strip leading bit of n = 0000_2.
16 is of bitsize 5.
Prepend 5-1 zeros and 5 as 101_2
0000101_2 + 0000_2 = 00001010000_2 = 80.
		

Crossrefs

Cf. A281150.

Programs

  • Mathematica
    A380934[n_] := FromDigits[Join[IntegerDigits[BitLength[n], 2], Rest[IntegerDigits[n, 2]]], 2] (* James C. McMahon, Apr 30 2025 *)
  • Python
    def a(n):
        if n == 1: return 1
        b = bin(n)[2:]
        L = len(b)
        g = '0' * (L - 1) + bin(L)[2:]
        d = g + b[1:]
        return int(d,2)
    print([a(n) for n in range(1,60)])
    
  • Python
    def A380934(n): return int(bin(n.bit_length())+bin(n)[3:],2) # Chai Wah Wu, Apr 21 2025