login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A319733 a(n) is the sum of the digits of all positive integers k <= 2^n. 0

%I #24 Nov 09 2018 20:40:59

%S 1,3,10,36,73,177,460,1083,2395,5616,13645,28410,61237,139332,288640,

%T 617238,1349299,2868414,5996665,12814005,28009981,57356550,119204515,

%U 256361433,523470583,1084937169,2295828010,4741694379,9785380105,20385048345,43120114795,87517507827,180053228620,379360852038,769412529055

%N a(n) is the sum of the digits of all positive integers k <= 2^n.

%C Inspired by A114136.

%e a(0) = 1;

%e a(1) = 3 = 1+2;

%e a(2) = 10 = 1+2+3+4;

%e a(3) = 36 = 1+2+3+4+5+6+7+8;

%e a(4) = 73 = 1+2+3+4+5+6+7+8+9+(1+0)+(1+1)+(1+2)+(1+3)+(1+4)+(1+5)+(1+6);

%e a(5) = 177 = 1+2+3+4+5+6+7+8+9+(1+0)+(1+1)+(1+2)+(1+3)+(1+4)+(1+5)+(1+6)+(1+7)+(1+8)+(1+9)+(2+0)+(2+1)+(2+2)+(2+3)+(2+4)+(2+5)+(2+6)+(2+7)+(2+8)+(2+9)+(3+0)+(3+1)+(3+2); etc.

%t k = s = 0; lst = {}; Do[ While[k <= 2^n, s = s + Plus @@ IntegerDigits@ k; k++]; AppendTo[lst, s], {n, 0, 32}] (* slow, or *)

%t f[n_, d_ /; d > 0, b_: 10] := Sum[k = n + 1; j = Mod[Floor[k/b^i], b]; j*i*b^(i - 1) + Mod[k, b^i]*Boole[j == d] + b^i*Boole[j > d > 0], {i, 0, Log[b, k]}]; (* calculates the number of times the digit, 0<d<b, appears in the integers 1 to n in base b. The count for d=0 is incorrect. *)

%t g[n_, b_: 10] := Plus @@ ((f[n, #, b] & /@ Range[b - 1])*Range[b - 1]); Array[ g[2^#] &, 33, 0]

%o (PARI) a(n) = sum(k=0, 2^n, sumdigits(k)); \\ _Michel Marcus_, Sep 27 2018

%Y Cf. A034967, A037123, A114136.

%K base,nonn

%O 0,2

%A Joseph K. Horn and _Robert G. Wilson v_, Sep 26 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 18:16 EDT 2024. Contains 371916 sequences. (Running on oeis4.)