login
Write out the digits of the integers in order (cf. A007376): 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 ...; a(n) = sum of digits between successive zeros.
2

%I #6 Mar 06 2018 14:52:29

%S 0,46,56,66,76,86,96,106,116,126,127,0,1,2,3,4,5,6,7,8,9,11,66,76,86,

%T 96,106,116,126,136,137,0,2,3,4,5,6,7,8,9,10,12,76,86,96,106,116,126,

%U 136,146,147,0,3,4,5,6,7,8,9,10,11,13,86,96,106,116,126,136,146,156,157,0,4

%N Write out the digits of the integers in order (cf. A007376): 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 ...; a(n) = sum of digits between successive zeros.

%C a(0) = 0 by convention.

%p c:=proc(x,y) local s: s:=proc(m) nops(convert(m,base,10)) end: if y=0 then 10*x else x*10^s(y)+y: fi end: b:=proc(n) local nn: nn:=convert(n,base,10): [seq(nn[nops(nn)+1-i],i=1..nops(nn))] end: A:=0: for n from 1 to 500 do A:=c(A,n) od: B:=[0,seq(b(A)[j],j=1..nops(b(A)))]: u:=proc(n) if B[n]=0 then n else fi end: U:=[seq(u(n),n=1..nops(B))]: 0,seq(add(B[j],j=U[i]..U[i+1]),i=1..nops(U)-1); # there must exist a simpler Maple program! - _Emeric Deutsch_, Jul 27 2006

%p #alternative

%p A119385 := proc(n) option remember ; local nupto,a,a007376,k ; if n =0 then RETURN([0,0]) ; else nupto := op(2,A119385(n-1)) ; a := 0 ; for k from nupto+1 do a007376 := A007376(k) ; if op(1,a007376) > 0 then a := a+op(1,a007376) ; else RETURN([a,k]) ; fi ; od: fi ; end :# _R. J. Mathar_, Jan 21 2008

%t list1=Flatten[Table[IntegerDigits[i],{i,0,1000}]];

%t index1=Partition[Flatten[Position[list1,0]],2,1];

%t Plus@@@Table[Take[list1,Flatten[Take[index1,{i}]]],{i,Length[index1]}] (From Harvey Dale)

%K nonn,base,easy

%O 0,2

%A _N. J. A. Sloane_, Jul 26 2006

%E More terms from _Emeric Deutsch_, Jul 27 2006