e Digits

Author

Eric W. Weisstein
September 12, 2013

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Constants/eDigits.nb.

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

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

Digit Computation

N[E,20]

Compute

(10^9)

{$MachineName,$TopDirectory,DateString[],$Version}//Column

cons=N[E,1*^9];//Timing

DumpSave["/Developer/eww/Constants/E_10_9.mx",cons];

{ByteCount[cons],MaxMemoryUsed[]}/10^9. GB

(10^10)

{$MachineName,$TopDirectory,DateString[],$Version}//Column

Precision[cons=N[E,1*^10+10]]//Timing

{ByteCount[cons],MaxMemoryUsed[]}/10^9. GB

DumpSave["/Developer/eww/Constants/E_10_10.mx",cons];

(10^11)

{$MachineName,$TopDirectory,DateString[],$Version}//Column

Precision[cons=N[E,1*^11+10]]//Timing

{ByteCount[cons],MaxMemoryUsed[]}/10^9. GB

DumpSave["/Developer/eww/Constants/E_10_11.mx",cons];

Read from file

Get["/Developer/eww/Constants/E_10_9.mx"];//Timing//AbsoluteTiming

{Precision[cons],ByteCount[cons]/10^9. GB}

Convert to String

(10^9)

StringLength[string=StringDrop[ToString[cons],2]]//Timing

StringTake[string,10]

(10^10)

StringLength[string=StringTake[ToString[cons],{3,-3}]]//Timing

StringTake[string,10]

Save String to File

DumpSave["/Developer/eww/DigitStrings/E_10_9.mx",string];

DumpSave["/Developer/eww/DigitStrings/E_10_10.mx",string];

Get String from file

Get["/Developer/eww/DigitStrings/E_10_9.mx"];//Timing//AbsoluteTiming

Digit Distribution

(10^10) using StringCount

(2^31)-1

10^10>(2^31)-1

(digits=Table[{n,StringCount[StringTake[string,10^n],#]&/@CharacterRange["0","9"]},{n,10}])//Timing

Grid[digits,Dividers->All,Alignment->Left]

A224615 to A224818

MapIndexed[{#2[[1]]-1,#}&,Transpose[digits[[All,2]]]]

(10^10) manually partitioning string

StringPartition[s_String,chunksize_]:=Module[{len=StringLength[s],k},If[chunksize>len,{s},StringTake[s,#]&/@Table[{1+(k-1) chunksize,Min[len,k chunksize]},{k,Ceiling[len/chunksize]}]]]

BigStringCount[s_,c_,chunksize_:(2^31)-1]:=Total[StringCount[#,c]&/@StringPartition[s,chunksize]]

(digits=Table[{n,BigStringCount[StringTake[string,10^n],#,(2^31)-1]&/@CharacterRange["0","9"]},{n,10}])//Timing

Grid[digits,Dividers->All,Alignment->Left]

A224615 to A224818

MapIndexed[{#2[[1]]-1,#}&,Transpose[digits[[All,2]]]]

Digit Runs

k n’s

(10^9)

StringLength[string]

(data=Flatten[Table[{d,n,If[#=={},0,First[#]]&/@StringPosition[string,StringJoin@@Table[ToString[d],{n}],10]},{d,0,9},{n,9}],1])//Timing

Grid[DeleteCases[data,{_,_,{}}],Dividers->All,Alignment->Left]

(10^10)

StringLength[string]

(data=Flatten[Table[{d,n,If[#=={},0,First[#]]&/@StringPosition[string,StringJoin@@Table[ToString[d],{n}],10]},{d,0,9},{n,10}],1])//Timing

Grid[DeleteCases[data,{_,_,{}}],Dividers->All,Alignment->Left]

n n’s (Earls Sequence)

A224819

(10^9)

Cases[DeleteCases[data,{_,_,{}}],{x_,x_,s_}:>s[[1]]]

(10^10)

StringLength[string]

earls=Cases[DeleteCases[data,{_,_,{}}],{x_,x_,s_}:>{x,s[[1]]}]

earls[[All,2]]

Length[earls]

Scan until all n-digits strings have been found

A036900

A036904

Length[realdigits]//N

Do[Print[{n,ScanDigitStrings[realdigits,n]//Timing}],{n,9}]

First digit string occurrences

A088576

Length[f=FirstDigitOccurrences[realdigits,5]]//Timing

Take[f,100]

Length[f=FirstDigitOccurrences[realdigits,6]]//Timing

Position[f,0]

Specific Digits Runs

StringLength[string]

0123456789

StringPosition[string,"0123456789"]//Timing

9876543210

StringPosition[string,"9876543210"]//Timing