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.

A273004 Sum of coefficients in the hereditary representation of n in base 2.

This page as a plain text file.
%I A273004 #39 Aug 25 2025 04:43:28
%S A273004 0,1,2,3,3,4,5,6,4,5,6,7,7,8,9,10,4,5,6,7,7,8,9,10,8,9,10,11,11,12,13,
%T A273004 14,5,6,7,8,8,9,10,11,9,10,11,12,12,13,14,15,9,10,11,12,12,13,14,15,
%U A273004 13,14,15,16,16,17,18,19,6,7,8,9,9,10,11,12,10,11,12,13,13,14,15,16,10,11,12,13,13,14,15,16,14,15,16,17,17,18,19,20,11,12,13,14,14
%N A273004 Sum of coefficients in the hereditary representation of n in base 2.
%C A273004 The hereditary representation of a number n in base b is a [possibly empty] sum (possibly represented as a list) of monomials of the form m*b^e (possibly represented as a list [m,e] or as a single number m if e = 0) with coefficients 0 < m < b, and the (strictly increasing) exponents e > 0 recursively again expressed in the same form. Thus 0 = [], 1 = 1*b^0 = [1], b = 1*b^1 = [[1, [1]]] etc.
%H A273004 Andrei Zabolotskii, <a href="/A273004/b273004.txt">Table of n, a(n) for n = 0..8191</a>
%H A273004 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/HereditaryRepresentation.html">Hereditary Representation</a>.
%F A273004 If n = Sum_{j=1..k} 2^e_j where 0 <= e_1 < ... < e_k, then a(n) = k + Sum_{j=1..k} a(e_j). - _Pontus von Brömssen_, Sep 17 2020
%F A273004 a(n) = A033922(n) + A361838(floor(n/2)) for n > 1. - _Andrei Zabolotskii_, Aug 24 2025
%e A273004 266 = 1*2^1 + 1*2^(1+1*2^1) + 1*2^(1*2^(1+1*2^1)) which can be represented as [[1, [1]], [1, [1, [1, [1]]]], [1, [[1, [1, [1, [1]]]]]]], and there are 11 "1"s, therefore a(266) = 11.
%t A273004 a[n_] := a[n] = Total[1 + a /@ Log2[DeleteCases[NumberExpand[n, 2], 0]]]; (* _Vladimir Reshetnikov_, Dec 21 2023 *)
%o A273004 (PARI) (hr(n,b=2)=if(1<#n=digits(n,b),my(v=if(n[#n],[n[#n]],[]));forstep(i=#n-1,1,-1,n[i]&&v=concat(v,[[n[i],hr(#n-i,b)]]));v,n));(cc(v)=if(type(v)=="t_VEC",sum(i=1,#v,cc(v[i])),v)); a(n)=cc(hr(n))
%o A273004 (Python)
%o A273004 def A273004(n):
%o A273004   s=format(n,'b')[::-1]
%o A273004   return sum(1+A273004(i) for i in range(len(s)) if s[i]=='1') # _Pontus von Brömssen_, Sep 17 2020
%Y A273004 Cf. A056004, A222112, A273005 (base 10 analog), A033922, A361838.
%K A273004 nonn,base,changed
%O A273004 0,3
%A A273004 _M. F. Hasler_, May 12 2016