Kaprekar Number

Author

Eric W. Weisstein
November 30, 2003

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

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

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

Code

KaprekarQ[n_]:=Module[{d=IntegerDigits[n^2],h},
h=Floor[Length[d]/2];
Plus@@FromDigits/@{Take[d,h],Take[d,h-Length[d]]}==n
]

Enumeration

Select[Range[10000],KaprekarQ]//Timing

Select[Range[10^6],KaprekarQ]//Timing