Smith Number

Author

Eric W. Weisstein
March 4, 2005

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegerSequences/SmithNumber.nb.

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

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

Code

DigitSum[n_,b_:10]:=Plus@@IntegerDigits[n,b]

SmithQ[n_Integer]:=SmithQ[1,n]
SmithQ[k_,p_Integer?PrimeQ]:=False
SmithQ[k_,n_Integer]:=DigitSum[n]==Plus@@DigitSum/@Flatten[Table[#1,{#2}]&@@@FactorInteger[n]]/k

Smith Numbers

Select[Range[1000],SmithQ]//Timing

2-Smith

Select[Range[1000],SmithQ[#,2]&]//Timing

3-Smith

Select[Range[10^5],SmithQ[#,3]&]//Timing

4-Smith

Select[Range[10^5],SmithQ[#,4]&]//Timing

Plot

<<Utilities`Plot`

Show[PixelPerfect[NaryPlot[Select[Range[1.5 10^4],SmithQ]]]]

Smith Brothers

(SmithBrothers=Transpose[Select[Partition[Select[Range[2,10^5],SmithQ[#]&],2,1],Subtract@@#==-1&]])//Timing