A   Narcissistic decimal number   is a non-negative integer,   



n


{\displaystyle n}

,   that is equal to the sum of the   



m


{\displaystyle m}

-th   powers of each of the digits in the decimal representation of   



n


{\displaystyle n}

,   where   



m


{\displaystyle m}

   is the number of digits in the decimal representation of   



n


{\displaystyle n}

.



Narcissistic (decimal) numbers are sometimes called   Armstrong   numbers, named after Michael F. Armstrong.

They are also known as   Plus Perfect   numbers.



An example

   if   



n


{\displaystyle n}

   is   153 
   then   



m


{\displaystyle m}

,   (the number of decimal digits)   is   3 
   we have    13 + 53 + 33   =   1 + 125 + 27   =   153  
   and so   153   is a narcissistic decimal number


Task

Generate and show here the first   25   narcissistic decimal numbers.



Note:   




0

1


=
0


{\displaystyle 0^{1}=0}

,   the first in the series.



See also

   the  OEIS entry:     Armstrong (or Plus Perfect, or narcissistic) numbers.
   MathWorld entry:   Narcissistic Number.
   Wikipedia entry:     Narcissistic number.


 
#NoEnv ; Do not try to use environment variables
SetBatchLines, -1 ; Execute as quickly as you can
 
StartCount := A_TickCount
Narc := Narc(25)
Elapsed := A_TickCount - StartCount
 
MsgBox, Finished in %Elapsed%ms`n%Narc%
return
 
Narc(m)
{
	Found := 0, Lower := 0
	Progress, B2
	Loop
	{
		Max := 10 ** Digits:=A_Index
		Loop, 10
			Index := A_Index-1, Powers%Index% := Index**Digits
		While Lower < Max
		{
			Sum := 0
			Loop, Parse, Lower
				Sum += Powers%A_LoopField%
			Loop, 10
			{
 
				if (Lower + (Index := A_Index-1) == Sum + Powers%Index%)
				{
					Out .= Lower+Index . (Mod(++Found,5) ? ", " : "`n")
					Progress, % Found/M*100
					if (Found >= m)
					{
						Progress, Off
						return Out
					}
				}
			}
			Lower += 10
		}
	}
}
 