Finding self-loving and narcissistic numbers

The number 153 (hundred and fifty three) in front for a forest. Generated with Adobe Firefly.

What if there existed some special numbers, positive integers where the sum of the powered digits, ends up at the original number?

Such numbers exists and are called self-loving or narcissistic numbers, due to the self-orientated property. They are also sometimes called Perfect Digital Invariants (PDI) too, with a difference from self-loving numbers because they can exist in any number base, not just base-10.

Okay, take for example the number 42.

The sum of the digits 4 and 2 to the power of three would be

42 = 4³ + 2³ = 64 + 8 = 72

72 is not the same number as 42 and therefore this is not a perfect digital invariant or self-loving number.

How can we find such numbers then? You could manually check all known integers, but this will take forever. As with other such number hunting endevours, you can use programming.

I wrote a tiny script in Python, and it turns out there are just a tiny collection of numbers with this curious self-orientated property. Those few also seem to be found in the powers 3,4 and 5.

I let the computer try this math on all numbers between 2 (no need to check 1) and one million, using the power three (n³), the following numbers stands out:

153, 370, 371, 407

Only four such numbers. Let us check 153 manually to verify this:

153 = 1³ + 5³ + 3³ = 1 + 125 + 27 = 153

Look at that, we end up are the starting point. If we choose the power four, we get these three:

1634, 8208, 9474

And power of five, we get these ones:

4150, 4151, 54748, 92727, 93084, 194979

We could plot them and see how they are scattered on a canvas:

Any other curious properties to these Perfect Digital Invariants?

None of these numbers are either palindrome or prime numbers. But some of them are having the same number of digits as the chosen power when looking for them ten in total, that is for the base ten numbering system..

153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084