Digit Sum

Author

Eric W. Weisstein
June 2, 2023

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Numbers/DigitSum.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/DigitSum.html.

©2023 Wolfram Research, Inc. except for portions noted otherwise

Initialization

DigitSum[n_,b_:10]:=Total[IntegerDigits[n,b]]
DigitSum2[n_,b_:10]:=Range[0,b-1].RotateRight[DigitCount[n,b]]

Check

Table[DigitSum[n,b]-DigitSum2[n,b],{n,10},{b,2,5}]

Plots

Table[DigitSum[n,b],{b,2,10},{n,15}]//ColumnForm

ListDensityPlot[Table[DigitSum[n,b],{b,2,100},{n,100}],Mesh->False,ColorFunction->Hue,FrameLabel->{b,n,(Subscript[s, b])[n],""},LabelStyle->{14,Black,FontFamily->"Times"}]

GraphicsGrid[
Partition[
Table[
ListPlot[DigitSum[#,b]&/@Range[1000],
PlotStyle->{Red},
PlotLabel->HoldForm[Style["b",Italic]]==b,
AxesLabel->Thread[Style[{n,(Subscript[s, b])[n]},14]],
BaseStyle->{Black,FontFamily->"Times"},
LabelStyle->{Black,FontFamily->"Times"},
PlotRangePadding->None
],
{b,2,10}],
UpTo[3]
],ImageSize->500,Spacings->{-50,20}]

bug(437129): Plot and Tick labels cutoff in graphics grids

Sums

(∑_n^∞)((DigitSum[n,b,1])/(n (n+1)))==((b log(b))/(b-1))

TextGrid[N[Table[{
Total@Table[((DigitSum[n,b])/(n(n+1))),{n,3000}],
b/(b-1)Log[b]
},{b,2,10}],20],Dividers->All]

(∑_n^∞)((DigitCount[n,2,1])/(n (n+1)))==2 log(2)

Sum[((DigitCount[n,2,1])/(n(n+1))),{n,∞}]//Timing

Sum[((DigitCount[n,2,1])/(n(n+1))),{n,(10^5)}]//N

2Log[2]//N

(∑_n^∞)(((2 n+1) DigitCount[n,2,1])/((n^2) (((n+1))^2)))==((π^2)/9)

Sum[DigitCount[n,2,1]((2n+1)/((n^2)(((n+1))^2))),{n,∞}]//Timing

N[(Pi^2)/9]

Sum[DigitCount[n,2,1]((2n+1)/((n^2)(((n+1))^2))),{n,10^5}]//N

(∑_(n=2)^∞)(((8 (n^3)+4 (n^2)+n-1) ((DigitCount[n,2,1])^2))/(4 n ((n^2)-1) (4 (n^2)-1)))==(17/24)+log(2)

Sum[((DigitCount[n,2,1])^2)((8(n^3)+4(n^2)+n-1)/(4n((n^2)-1)(4(n^2)-1))),{n,2,∞}]//Timing

N[(17/24)+Log[2]]

Sum[((DigitCount[n,2,1])^2)((8(n^3)+4(n^2)+n-1)/(4n((n^2)-1)(4(n^2)-1))),{n,2,(10^5)}]//N

Product[(((((b n+k)/(b n+k+1))))^(((-1))^(DigitSum(n,b)))),{k,1,b-1,2},{n,0,∞}]==(1/(Sqrt[b]))

Table[Product[(((((n b+k)/(n b+k+1))))^((-1)^DigitSum[n,b])),{k,1,b-1,2},{n,0,1000}],{b,2,10}]//N

1/%^2

(∑_n^∞)((u(n))/(n (n+1)))==((3 log(2))/2)-(π/4)

Sum of (1, 1)-blocks

u[n_,b_,block_]:=Count[Partition[IntegerDigits[n,b],Length[block],1],block]

N[(3/2)Log[2]-(Pi/4)]

Sum[((u[n,2,{1,1}])/(n(n+1))),{n,(10^5)}]//N

Products

(∏_(n=0)^∞)(((((2 n+1)/(2 n+2))))^(((-1))^(DigitSum(n,2))))==((Sqrt[2])/2)

Product[(((((2n+1)/(2n+2))))^(((-1))^(DigitCount[n,2,1]))),{n,0,∞}]//Timing

((Sqrt[2])/2)//N

Product[(((((2n+1)/(2n+2))))^(((-1))^(DigitSum[n,2]))),{n,0,(10^5)}]//N

Product[(((((2n+1)/(2n+2))))^(((-1))^(DigitCount[n,2,1]))),{n,0,(10^5)}]//N

Product of Digit Sum and Its Reversal

A110921

Reversal[n_Integer,b_:10]:=FromDigits[Reverse[IntegerDigits[n,b]],b]

Position[#-(s=DigitSum[10,#])Reversal[s]&/@Range[10^7],0]//Flatten//Timing

Iterated Digit Sum

ψ[b_Integer/;b>=2,n_Integer?Positive]:=FixedPoint[DigitSum[#,b]&,n]

ListDensityPlot[Table[ψ[b,n],{b,2,100},{n,100}],Mesh->False,ColorFunction->Hue,FrameLabel->{b,n,(Subscript[ψ, b])[n],""},LabelStyle->{Black,14,FontFamily->"Times"}]