Munchausen numbers

func is_munchausen(n) {
    n.digits.map{|d| d**d }.sum == n
}
 
say (1..5000 -> grep(is_munchausen))

Output:

[1, 3435]

Last updated