A Munchausen number is a natural number n the sum of whose digits (in base 10), each raised to the power of itself, equals n.

(Munchausen is also spelled: Münchhausen.)

For instance:    3435 = 33 + 44 + 33 + 55 



Task
Find all Munchausen numbers between   1   and   5000.



Also see

 The OEIS entry:  A046253
 The Wikipedia entry:  Perfect digit-to-digit invariant, redirected from Munchausen Number


// split numer into digits
digits n::number = loop n [] with
                     loop n l = loop (n div 10) ((n mod 10):l) if n > 0;
                              = l otherwise; end;
 
munchausen n::int = (filter isMunchausen list) when
                      list = 1..n; end with
                      isMunchausen n = n == foldl (+) 0
                                       (map (\d -> d^d)
                                        (digits n)); end;
munchausen 5000;