%I #28 Dec 20 2024 02:44:44
%S 0,2,11,38,109,284,699,1658,3833,8696,19447,42998,94197,204788,442355,
%T 950258,2031601,4325360,9175023,19398638,40894445,85983212,180355051,
%U 377487338,788529129,1644167144,3422552039,7113539558,14763950053
%N Sum of binary numbers with n 1's and one (non-leading) 0.
%C For n>0, a(n) = sum of n-th row of the triangle in A164874. [_Reinhard Zumkeller_, Aug 29 2009]
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (6,-13,12,-4).
%F a(n) = (2n-1)*2^n+1-n.
%F G.f.: -x*(2*x^2+x-2) / ((x-1)^2*(2*x-1)^2). - _Colin Barker_, Sep 14 2014
%F a(0)=0, a(1)=2, a(2)=11, a(3)=38, a(n)=6*a(n-1)-13*a(n-2)+ 12*a(n-3)- 4*a(n-4). - _Harvey P. Dale_, May 17 2015. [This is equivalent to the g.f. -x*(2*x^2+x-2) / ((x-1)^2*(2*x-1)^2) given by _Colin Barker_. - _N. J. A. Sloane_, May 17 2015]
%e a(4)=109 since the binary sum 11110+11101+11011+10111 is 30+29+27+23.
%p A059673:=n->(2*n-1)*2^n+1-n: seq(A059673(n), n=0..50); # _Wesley Ivan Hurt_, Apr 24 2017
%t Table[Total[FromDigits[#,2]&/@Rest[Permutations[PadRight[{0},n,1]]]],{n,30}] (* or *) LinearRecurrence[{6,-13,12,-4},{0,2,11,38},30] (* _Harvey P. Dale_, May 17 2015 *)
%o (PARI) concat(0, Vec(-x*(2*x^2+x-2)/((x-1)^2*(2*x-1)^2) + O(x^100))) \\ _Colin Barker_, Sep 14 2014
%o (Python)
%o def A059673(n): return ((n<<1)-1<<n)-n+1 # _Chai Wah Wu_, Dec 19 2024
%Y Cf. A030130, A164874. [From _Reinhard Zumkeller_, Aug 29 2009]
%K easy,nonn,base
%O 0,2
%A _Henry Bottomley_, Feb 05 2001