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...




main =>
  Limit = 19,
  D = [],
  N = 0,
  printf("The first %d Disarium numbers are:\n",Limit),  
  while (D.len < Limit)
     if disarium_number(N) then
       D := D ++ [N]
     end,
     N := N + 1,
     if N mod 10_000_000 == 0 then
       println(test=N)
     end
  end,
  println(D).
 
disarium_number(N) =>
  Sum = 0,
  Digits = N.to_string.len,
  X = N,
  while (X != 0, Sum <= N)
    Sum := Sum + (X mod 10) ** Digits,
    Digits := Digits - 1,
    X := X div 10
  end,
  Sum == N.