func is_munchausen(n) { n.digits.map{|d| d**d }.sum == n } say (1..5000 -> grep(is_munchausen))
[1, 3435]
Last updated 1 year ago