Mertens Function

Author

Eric W. Weisstein
May 23, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheoreticFunctions/MertensFunction.nb.

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

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

Code

Mertens[x_]:=Total[MoebiusMu[Range[1,x]]]
Mertens[{1,x_}]:=Rest@FoldList[Plus,0,MoebiusMu[Range[1,x]]]
SetAttributes[Mertens,Listable];

Enumeration

Mertens[Range[100]]

{#[[1,1]],Last/@#}&/@Split[Sort[Table[{Mertens[n],n},{n,1000}]],#1[[1]]==#2[[1]]&]//ColumnForm

Plot

<<Utilities`Plot`

Show[GraphicsArray[
Block[{$DisplayFunction=Identity},
IntegerListPlot[Mertens[{1,#}],AxesLabel->TraditionalForm/@{n,M[n]}]&/@{100,1000}
]
]]

Table

With[{n=6},
Mertens[{1,10^6}][[Table[10^k,{k,0,n}]]]
]//Timing