A Disarium number is an integer where the sum of each digit raised to the power of its position in the number, is equal to the number.



E.G.
135 is a Disarium number:

 11 + 32 + 53 == 1 + 9 + 125 == 135

There are a finite number of Disarium numbers.



Task
 Find and display the first 18 Disarium numbers.


Stretch
 Find and display all 20 Disarium numbers.


See also
 Geeks for Geeks - Disarium numbers
 OEIS:A032799 - Numbers n such that n equals the sum of its digits raised to the consecutive powers (1,2,3,...)
 Related task: Narcissistic decimal number
 Related task: Own digits power sum Which seems to be the same task as Narcissistic decimal number...




func Disarium(N);       \Return 'true' if N is a Disarium number
int  N, N0, D(10), A(10), I, J, Sum;
[N0:= N;
for J:= 0 to 10-1 do A(J):= 1;
I:= 0;
repeat  N:= N/10;
        D(I):= rem(0);
        I:= I+1;
        for J:= 0 to I-1 do
            A(J):= A(J) * D(J);
until   N = 0;
Sum:= 0;
for J:= 0 to I-1 do
    Sum:= Sum + A(J);
return Sum = N0;
];
 
int Cnt, N;
[Cnt:= 0;  N:= 0;
loop    [if Disarium(N) then
            [IntOut(0, N);  ChOut(0, ^ );
            Cnt:= Cnt+1;
            if Cnt >= 19 then quit;
            ];
        N:= N+1;
        ];
]