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.


1 DEFINT A-W : DEFDBL X-Z : DIM D(9) : DIM X2(9) : KEY OFF : CLS
2 FOR A = 0 TO 9 : X2(A) = A : NEXT A
3 FOR N = 1 TO 7
4 FOR N9 = N TO 0 STEP -1
5 FOR N8 = N-N9 TO 0 STEP -1
6 FOR N7 = N-N9-N8 TO 0 STEP -1
7 FOR N6 = N-N9-N8-N7 TO 0 STEP -1
8 FOR N5 = N-N9-N8-N7-N6 TO 0 STEP -1
9 FOR N4 = N-N9-N8-N7-N6-N5 TO 0 STEP -1
10 FOR N3 = N-N9-N8-N7-N6-N5-N4 TO 0 STEP -1
11 FOR N2 = N-N9-N8-N7-N6-N5-N4-N3 TO 0 STEP -1
12 FOR N1 = N-N9-N8-N7-N6-N5-N4-N3-N2 TO 0 STEP -1
13 N0 = N-N9-N8-N7-N6-N5-N4-N3-N2-N1
14 X = N1 + N2*X2(2) + N3*X2(3) + N4*X2(4) + N5*X2(5) + N6*X2(6) + N7*X2(7) + N8*X2(8) + N9*X2(9)
15 S$ = MID$(STR$(X),2)
16 IF LEN(S$) < N THEN GOTO 25
17 IF LEN(S$) <> N THEN GOTO 24
18 FOR A = 0 TO 9 : D(A) = 0 : NEXT A
19 FOR A = 0 TO N-1 
20 B = ASC(MID$(S$,A+1,1))-48
21 D(B) = D(B) + 1
22 NEXT A
23 IF N0 = D(0) AND N1 = D(1) AND N2 = D(2) AND N3 = D(3) AND N4 = D(4) AND N5 = D(5) AND N6 = D(6) AND N7 = D(7) AND N8 = D(8) AND N9 = D(9) THEN PRINT X,
24 NEXT N1 : NEXT N2 : NEXT N3 : NEXT N4 : NEXT N5 : NEXT N6 : NEXT N7 : NEXT N8 : NEXT N9
25 FOR A = 2 TO 9
26 X2(A) = X2(A) * A
27 NEXT A
28 NEXT N
29 PRINT
30 PRINT "done"
31 END