# Find an instance of a Kaprekar number

Here are two instances of an Kaprekar number

$$\text{9{}^{\wedge} 2 = 81 \& 8+1=9}$$

$$\text{8{}^{\wedge} 3 = 512 \& 5+1+2=8}$$

There are certainly more with a higher exponent , perhaps an infinite number of them.

However with the line of code below

FindInstance[ x^y == z  && x > 1 && y > 1  && Total[IntegerDigits[z]] == x, {x, y, z}, Integers, 1]


MMA V11.3 does not return a single instance. Is there anything wrong in this code or is it a limitation of the FindInstance function ?

• Just curious: you write the formulas in LaTeX, which is a way to typeset traditional mathematical notation on a computer, but you make special effort to make it look like computer code regardless. Why? – Szabolcs Feb 22 at 12:57
• 12.0 gives you a reason: "The methods available to FindInstance are insufficient to find the requested instances or prove they do not exist." If you reformulate the problem to avoid Total and IntegerDigits, then it works, but then we need to hard-code the number of digits. – Szabolcs Feb 22 at 13:11
• Your definition of a Kaprekar number does not agree with the definition given in MathWorld or OEIS A006886. For those definitions, 8 is not a Kaprekar number. The OEIS gives the Mathematica code written by T. D. Noe which generates 1035 Kaprekar numbers. – Bob Hanlon Feb 22 at 14:01
• According to mrob 8 is an order-3 Kaprekar number and 9 an order-2 (normal) one. The contents of your links don't contradict the one I point to but they are not as exhaustive. True I overlooked in my code to divide z into y equal pieces before adding them up.But I know now from the answer received that FindInstance is not up to the task even with V12.0 (version I don't have) which at first not evident. – Sigis K Feb 22 at 18:48

Brute-force search will be much better here than FindInstance.
In[16]:= First@Last@Reap@Do[